Using Selenium in the background

前端 未结 1 455
时光说笑
时光说笑 2020-12-16 04:14

I\'m using Selenium and chrome webdriver but when I run scripts it opens a window. Is there any way that it can access the internet without the window popping up?

         


        
相关标签:
1条回答
  • 2020-12-16 04:22

    I would suggest try using headless PhantomJs GhostDriver (which is a relatively new thing). As this is the native Selenium Webdriver way of doing it.

    Download PhantomJs executables from http://phantomjs.org/download.html.

    driver = webdriver.PhantomJS("./phantomjs") # path to phantomjs binary
    driver.get("https://ps.rsd.edu/public/")
    
    elem = driver.find_element_by_name("account")
    elem.send_keys("Username")
    elem2 = driver.find_element_by_name("pw")
    elem2.send_keys("Password")
    elem.send_keys(Keys.RETURN)
    
    driver.quit()
    
    0 讨论(0)
提交回复
热议问题