Finding Elements With Css Selenium

Finding Elements With Css Selenium

CSS Selectors are way to identify elements on the page.

Selenium can use CSS selectors to find elements, which then you can interact with (i.e. click, send keys, etc.).

For example, in Ruby:

require 'selenium-webdriver'

driver = Selenium::WebDriver.for(:firefox)

driver.get('https://saucelabs.com/test/guinea-pig')

input_element = driver.find_element(:css => '#the_forms_id input[type=text]')

input_element.clear()

input_element.send_keys('abc')


To learn more about using CSS Selectors with Selenium, check out our Selenium Bootcamp!