Switching into new window using Selenium after button click

后端 未结 1 657
傲寒
傲寒 2020-12-07 05:14

I\'m working on quite a simple webpage project and got stuck a bit. I\'m using a website that after filling the form and clicking the button gives me my desired data in for

相关标签:
1条回答
  • 2020-12-07 05:22

    The solution for your question will be to induce Explicitwait with expected_conditions as number_of_windows_to_be and then switch over to the new window as follows :

    parent = driver.current_window_handle
    button = browser.find_by_id('send')
    form.fill(string)
    button.click()
    WebDriverWait(driver, 10).until(
        EC.number_of_windows_to_be(2)
        )   
    child = driver.window_handles[1]      
    driver.switch_to_window(child) 
    print ("Child Window ID is : %s" %child)
    print("Child Window Title is : %s " %(driver.title)) 
    
    0 讨论(0)
提交回复
热议问题