-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDynamic_Dropdown.py
More file actions
27 lines (21 loc) · 816 Bytes
/
Dynamic_Dropdown.py
File metadata and controls
27 lines (21 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
#chrome driver without local chromedriver
service_obj = Service()
driver = webdriver.Chrome(service=service_obj)
driver.get("https://rahulshettyacademy.com/dropdownsPractise/")
driver.find_element(By.ID, "autosuggest").send_keys("Ind")
time.sleep(2)
#select all the elements with matching attribute
countries = driver.find_elements(By.CSS_SELECTOR, "li[class='ui-menu-item']")
print((len(countries)))
#Itterate for India in country and the click on that
for country in countries:
if country.text == "India":
country.click()
break
#print attribute of manual input
print(driver.find_element(By.ID, "autosuggest").get_attribute("value"))
driver.close()