Selenium Cheat Sheets 2

Embed Size (px)

Citation preview

  • 8/11/2019 Selenium Cheat Sheets 2

    1/6

  • 8/11/2019 Selenium Cheat Sheets 2

    2/6

  • 8/11/2019 Selenium Cheat Sheets 2

    3/6

    require'selenium-webdriver'

    Selenium::WebDriver::Chrome::Service.executable_path = './chromedriver'

    driver = Selenium::WebDriver.for :chrome

    require'selenium-webdriver'

    driver = Selenium::WebDriver.for :firefox

    require'selenium-webdriver'

    driver = Selenium::WebDriver.for :internet_explorer

    http://chromedriver.storage.googleapis.com/index.htmlhttps://code.google.com/p/selenium/wiki/ChromeDriverhttps://sites.google.com/a/chromium.org/chromedriver/homehttps://sites.google.com/a/chromium.org/chromedriver/homehttp://selenium-release.storage.googleapis.com/index.htmlhttp://www.computerhope.com/issues/ch000549.htmhttp://www.computerhope.com/issues/ch000549.htmhttp://selenium-release.storage.googleapis.com/index.htmlhttps://sites.google.com/a/chromium.org/chromedriver/homehttps://sites.google.com/a/chromium.org/chromedriver/homehttps://code.google.com/p/selenium/wiki/ChromeDriverhttp://chromedriver.storage.googleapis.com/index.html
  • 8/11/2019 Selenium Cheat Sheets 2

    4/6

    require'selenium-webdriver'

    ENV['SELENIUM_SERVER_JAR'] = './selenium-server-standalone.jar'

    driver = Selenium::WebDriver.for :opera

    driver.get 'http://www.google.com'

    driver.quit

    require'selenium-webdriver'

    driver = Selenium::WebDriver.for :safari

    https://code.google.com/p/selenium/wiki/InternetExplorerDriverhttp://selenium-release.storage.googleapis.com/index.htmlhttps://code.google.com/p/selenium/wiki/OperaDriverhttps://code.google.com/p/selenium/wiki/SafariDriverhttps://code.google.com/p/selenium/wiki/SafariDriverhttps://code.google.com/p/selenium/wiki/OperaDriverhttp://selenium-release.storage.googleapis.com/index.htmlhttps://code.google.com/p/selenium/wiki/InternetExplorerDriver
  • 8/11/2019 Selenium Cheat Sheets 2

    5/6

    driver.get 'url'# e.g., driver.get 'http://the-internet.herokuapp.com'

    # just one, the first Selenium finds

    driver.find_element(locator)

    # all instances of the element on the page

    driver.find_elements(locator)

    # returns an Array

    # Chain actions together

    driver.find_element(locator).click

    # Store the element

    element = driver.find_element(locator)

    element.click

    collection = driver.find_elements(locator)

    # by name

    collection.first.clickcollection.last.click

    # by index

    collection[0].click

    collection[-1].click

  • 8/11/2019 Selenium Cheat Sheets 2

    6/6

    element.click

    element.submit # submits a form

    element.clear # clearing an input field of its text

    element.send_keys # typing into an input field

    element.displayed? # is it visible?

    element.enabled? # can it be selected?

    element.selected? # is it selected?

    # by attribute name

    element.attribute('href')

    # directly from an element

    element.text

    attribute