python selenium-webdriver select option does not work

后端 未结 1 1708
北海茫月
北海茫月 2021-01-25 10:06

The selection of Calgary in Canadian Cities list does not work, it will always return All cities in the search result after clicking search button pro grammatically. Here is my

相关标签:
1条回答
  • 2021-01-25 10:27
    from selenium import webdriver
    from selenium.webdriver.support.ui import Select
    import time
    
    # Initialize
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.implicitly_wait(10)
    driver.get('https://sjobs.brassring.com/TGWebHost/searchopenings.aspx?partnerid=25222&siteid=5011')
    
    
    
    # Select city name Calgary
    text = "Calgary"  # what ever you want to select in dropdown
    currentselection = driver.find_element_by_id("Question4138__FORMTEXT62")
    select = Select(currentselection)
    select.select_by_visible_text(text)
    
    select.deselect_by_visible_text("All")
    
    print("Selected Calgary by visible text")
    
    driver.find_element_by_id('ctl00_MainContent_submit1').click()
    

    Hope this helps

    0 讨论(0)
提交回复
热议问题