Answers for "selenium find by element"

9

selenium finding elements

from selenium import webdriver

chrome_driver_path = 'C:Developmentchromedriver.exe'
driver = webdriver.Chrome(executable_path=chrome_driver_path)

driver.get('https://www.python.org')

name = driver.find_element_by_name('q')
print(name.get_attribute('placeholder'))

python_logo = driver.find_element_by_class_name('python-logo')
print(python_logo.size)

documentation_link = driver.find_element_by_css_selector('.documentation-widget a')
print(documentation_link.text)

anchor_xpath = driver.find_element_by_xpath('//*[@id="search"]/div[2]/div[6]/div[1]/div/div'))
print(anchor_xpath.text)
# you can get xpath by right click and inspect > right click on element > 
#  >> copy >>> XPath

# you can also search by class selector
# id_selector = driver.find_element_by_id('#id')

driver.quit()
Posted by: Guest on March-07-2021
0

selenium select element by id

driver.findElement(By.id("ui-datepicker-div"));
Posted by: Guest on June-05-2020
0

findelements in selenium

List<WebElement> elementName = driver.findElements(By.LocatorStrategy("LocatorValue"));
Posted by: Guest on November-19-2020
0

selenium ways of finding

elementcss= driver.findElement(By.cssSelector('div.nav-search-input'))
Posted by: Guest on May-01-2020
0

find by in selenium

FindBy is an annotation used in 
Page Object Model design pattern to identify the elements.
Posted by: Guest on January-30-2021

Code answers related to "selenium find by element"

Python Answers by Framework

Browse Popular Code Answers by Language