Click the javascript popup through webdriver

前端 未结 6 755
再見小時候
再見小時候 2020-12-05 10:58

I am scraping a webpage using Selenium webdriver in Python

The webpage I am working on, has a form. I am able to fill the form and then I click on the Submit button.

6条回答
  •  一生所求
    2020-12-05 11:23

    from selenium import webdriver
    from selenium.webdriver.support import expected_conditions as EC
    
    driver = webdriver.Firefox()
    #do something
    if EC.alert_is_present:
        print "Alert Exists"
        driver.switch_to_alert().accept()
        print "Alert accepted"
    else:
        print "No alert exists"
    

    More about excepted_conditions https://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html

提交回复
热议问题