while testing the dropdown in the phptravels site with selenium python i came across the issue.that i cannot select the value from dropdown

一个人想着一个人 提交于 2019-12-11 07:58:16

问题


The values are only loaded when we search with more than 3 keywords.

please help me to find a solution - my code is the following...

depart = driver.find_element_by_xpath("//a[contains(@class, 'select2-choice select2-default')]")
depart.click()
depart.select_by_value('Delhi Indira Gandhi Intl (DEL)')

回答1:


Here code you can try:

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait

wait = WebDriverWait(driver, 10)
#...
fromPlace = "Delhi Indira Gandhi"

#If will not enter text to FROM field, uncomment click code below 
#driver.find_elements_by_css_selector('#s2id_location_from a').click()
driver.find_element_by_id('s2id_autogen12').send_keys(fromPlace)

wait.until(EC.visibility_of_element_located((By.XPATH, "//div[@class='select2-result-label' and contains(.,'"+ fromPlace +"')]"))).click()


来源:https://stackoverflow.com/questions/52137903/while-testing-the-dropdown-in-the-phptravels-site-with-selenium-python-i-came-ac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!