Skip to content

Instantly share code, notes, and snippets.

View prashanth-sams's full-sized avatar
🍎
Each day is interesting!!!

Prashanth Sams prashanth-sams

🍎
Each day is interesting!!!
View GitHub Profile
@prashanth-sams
prashanth-sams / update_webdrivers.sh
Created November 25, 2018 07:55 — forked from cgoldberg/update_webdrivers.sh
Install geckodriver/chromedriver for Linux (64 bit)
#!/usr/bin/env bash
#
# Install WebDrivers for Linux
# ----------------------------
# * Binary webdrivers are required to drive Firefox and Chrome browsers from Selenium.
# * This script will fetch the 64-bit binaries (geckodriver/chromedriver) for Linux.
set -e
@prashanth-sams
prashanth-sams / geckodriver-install.sh
Created November 25, 2018 07:54 — forked from cgoldberg/geckodriver-install.sh
download and install latest geckodriver for linux or mac (selenium webdriver)
#!/bin/bash
# download and install latest geckodriver for linux or mac.
# required for selenium to drive a firefox browser.
install_dir="/usr/local/bin"
json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest)
if [[ $(uname) == "Darwin" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))')
elif [[ $(uname) == "Linux" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))')
@prashanth-sams
prashanth-sams / gist:946c292d0ce465fe704013918775d56a
Created May 3, 2018 08:37 — forked from gkop/gist:1371962
Capture javascript errors in Cucumber+Capybara+Webdriver tests
# in features/support/env.rb
require 'selenium/webdriver'
# we need a firefox extension to start intercepting javascript errors before the page
# scripts load
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
# see https://github.com/mguillem/JSErrorCollector
profile.add_extension File.join(Rails.root, "features/support/extensions/JSErrorCollector.xpi")
Capybara::Selenium::Driver.new app, :profile => profile
Given /I click_on "(.*)" "(.*)"/ do |value, type|
steps %Q{
And I wait until "#{value}" "#{type}" renders
}
@driver.find_element(type.to_sym => value).click
end
When /I wait for "(.*)" "(.*)" to render/ do |what, how|
start_time = Time.now.to_i
wait = Selenium::WebDriver::Wait.new(:timeout => 60)
Given /I click_on "(.*)" "(.*)"/ do |value, type|
steps %Q{
And I wait until "#{value}" "#{type}" renders
}
@driver.find_element(type.to_sym => value).click
end
When /I wait for "(.*)" "(.*)" to render/ do |what, how|
start_time = Time.now.to_i
wait = Selenium::WebDriver::Wait.new(:timeout => 60)
@prashanth-sams
prashanth-sams / map.json
Created July 24, 2017 07:27 — forked from ketanghumatkar/map.json
Leaflet MAP json sample
[
{
"_id":"577e9a7e664bdcee93000000",
"average_attendance":90,
"batch_code":"LALS010156",
"batch_id":"20160707T1807580000",
"batch_name":"LKSLST01/02/",
"batch_number":156,
"batch_pass_percentage":100,
"candidate_assessed":124,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@prashanth-sams
prashanth-sams / gist:5502337197e10e4564e5fadc7441944c
Created July 5, 2017 15:16 — forked from hmcgowan/gist:2272e0546964417d2163
Workaround for selenium-docker chrome hang
package com.lithium.mineraloil.selenium.browsers;
import com.lithium.mineraloil.selenium.DriverNotFoundException;
import lombok.Getter;
import lombok.Setter;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

DOs

2.hours.ago # => Thu, 27 Aug 2015 14:39:36 AFT +04:30
1.day.from_now # => Fri, 28 Aug 2015 16:39:36 AFT +04:30
Time.zone.parse("2015-08-27T12:09:36Z") # => Thu, 27 Aug 2015 16:39:36 AFT +04:30
Time.current # => Thu, 27 Aug 2015 16:39:36 AFT +04:30
Time.current.utc.iso8601 # When suppliyng an API ("2015-08-27T12:09:36Z")
Time.strptime("2015-08-27T12:09:36Z", "%Y-%m-%dT%H:%M:%S%z").in_time_zone # If you can't use Time.zone.parse (Thu, 27 Aug 2015 16:39:36 AFT +04:30)
Date.current # If you really can't have a Time or DateTime for some reason (Thu, 27 Aug 2015)
@prashanth-sams
prashanth-sams / ex-ssh-pty.rb
Created March 20, 2017 12:54 — forked from KINGSABRI/ex-ssh-pty.rb
ex. SSH with real PTY
require 'net/ssh'
host = "the.host"
user = "joe"
su_user = "bob"
password = "password"
commands = ["cd /", "pwd", "ls -l", "exit"]
finished = ("%08x" * 8) % Array.new(8) { rand(0xFFFFFFFF) }