Skip to content

Instantly share code, notes, and snippets.

@bootstraponline
bootstraponline / full-page-screenshots-selenium-chrome.rb
Created September 22, 2015 15:28 — forked from elcamino/full-page-screenshots-selenium-chrome.rb
How to take full-page screenshots with Selenium and Google Chrome in Ruby
#!/usr/bin/env ruby
require 'selenium-webdriver'
wd = Selenium::WebDriver.for :remote, url: 'http://10.3.1.7:4444/wd/hub', desired_capabilities: :chrome
wd.navigate.to 'https://snipt.net/restrada/python-selenium-workaround-for-full-page-screenshot-using-chromedriver-2x/'
# Get the actual page dimensions using javascript
#
width = wd.execute_script("return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);")
@bootstraponline
bootstraponline / gist:9d17040deb5b08dde28e
Last active August 29, 2015 14:25
Client Side Xpath
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

// id from R constant
String editTextUserInput = getTargetContext().getResources().getResourceName(R.id.editTextUserInput);
DroidDrivers.get().find(By.resourceId(editTextUserInput));
// hard coded id (same as above)
DroidDrivers.get().find(By.resourceId("com.example.android.testing.espresso.BasicSample:id/editTextUserInput"));
import collections, json
from urllib import urlretrieve
from urlparse import urljoin
from csv import DictReader, reader as csv_reader
import scrapinghub
from project.settings import SH_APIKEY
info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"ios","app":"/Users/tcollins/Documents/Git/bi-iPhone/iPhoneBI/build/Debug-iphonesimulator/iPhoneBI.app","#app":"/Users/tcollins/Documents/TestTools/appium/sample-code/apps/UICatalog/build/Release-iphonesimulator/UICatalog.app","deviceName":"iPhone Simulator"}}
debug: Appium request initiated at /wd/hub/session
info: <-- POST /wd/hub/session 303 1.583 ms - 9
debug: Request received with params: {"desiredCapabilities":{"platformName":"ios","app":"/Users/tcollins/Documents/Git/bi-iPhone/iPhoneBI/build/Debug-iphonesimulator/iPhoneBI.app","#app":"/Users/tcollins/Documents/TestTools/appium/sample-code/apps/UICatalog/build/Release-iphonesimulator/UICatalog.app","deviceName":"iPhone Simulator"}}
debug: Appium request initiated at /wd/hub/session/4e23b43c-111b-40e0-a10b-08cfa03126ce
debug: Request received with params: {}
debug: Responding to client with success: {"status":0,"value":{"webStorageEnabled":false,"locationContextEnabled":false,"brow
def desired_caps
{
caps: {
:'appium-version' => '1.1.0',
platformName: 'Android',
platformVersion: '4.2.2',
deviceName: 'Android Emulator',
app: '<path>'
#app: '<alternate_path>'
},
$ bin/test.sh --android
/usr/bin/xcode-select
RUNNING ANDROID TESTS
---------------------
process.env.LAUNCH_TIMEOUT --> undefined


  gappium
    HelloGappium
=begin
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ using indexPath: /0/0/0/0/2
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ before size: 6
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ after size: 6
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ index: 0
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ index: 0
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ index: 0
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ index: 0
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ index: 0
info: [UIAUTOMATOR STDOUT] ~~~~~~~~~~~~~~~~~ index: 2
$ node .
info: Welcome to Appium v0.17.6 (REV 60e9aa7fd5e1f0632fa459f37f08ba4f6158e8e6)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: socket.io started
info: Non-default server args: {"merciful":true}
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"platform":"Linux","platformVersion":"4.3","app":"/Users/user/training/modules/source/java_android/api.apk","platformName":"Android","device-type":"tablet","browserName":"android","name":"Java Android Training Wed Mar 26 22:18:07 EDT 2014","device-orientation":"portrait","version":"4.3"}}
warn: [DEPRECATED] The version capability has been deprecated and will be removed.  Please use the platformVersion capability instead.
info: No app-activity desired capability or server param. Parsing from apk.