Randomly Select From Dropdown List Python August 20, 2024 Post a Comment I am new in python selenium. I do not have any idea to do this. Please help. I appreciated. Solution 1: Try using random.choice:from selenium import webdriver import random driver = webdriver.Chrome() driver.get("https://account.magento.com/customer/account/create/") element = driver.find_element_by_xpath("//select[@id='country']") all_options = element.find_elements_by_tag_name("option") random_country = random.choice(all_options) print (random_country) CopySolution 2: import random country = [ "India", "China", "South Africa", "UAE", "UK", "Italy"] // Add your country hereprint(random.choice(country)) CopyUse random.choice() for random selection. Share Post a Comment for "Randomly Select From Dropdown List Python"
Post a Comment for "Randomly Select From Dropdown List Python"