headless-selenium-for-win using Python

半世苍凉 提交于 2019-12-11 07:51:20

问题


I found a headless IE from this github project headless-selenium-for-win

Which has the following files

desktop_utils.exe
headless_ie_selenium.exe

I extracted these files to C:\Selenium\headless-selenium

I used Selenium Python library to control IE(GUI) using IEDriverServer.exe which works well but when I use headless_ie_selenium.exe my script just went into endless execution and prints nothing.

Here is my Python Code

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


#driver = webdriver.Ie(r"C:/Selenium/IEDriverServer.exe")
driver = webdriver.Ie(r"C:/Selenium/headless-selenium/headless_ie_selenium.exe")
driver.get("www.google.com")
googleSearch = driver.find_element_by_name("q")
googleSearch.send_keys("Selenium")
googleSearch.send_keys(Keys.ENTER)

import time
time.sleep(4)

print driver.title

回答1:


I added the path of IEDriverServer.exe to System Variable path and after restarting my system the everything works fine.




回答2:


May be problem in slashes...

Your path: C:/Selenium/headless-selenium/headless_ie_selenium.exe

Try this: C:\Selenium\headless-selenium\headless_ie_selenium.exe

and another:

Your: driver.get("www.google.com")

Try this: driver.get("https://www.google.com")



来源:https://stackoverflow.com/questions/27748631/headless-selenium-for-win-using-python

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