开发者

How come I have this simple error in Selenium?

开发者 https://www.devze.com 2023-03-09 03:37 出处:网络
I\'m on AWS micro instance. There is no GUI. I SSH\'ed into it. pip install selenium sudo apt-get install firefox

I'm on AWS micro instance. There is no GUI. I SSH'ed into it.

pip install selenium
sudo apt-get install firefox

Then, I do this in the python shell:

>>> from selenium.webdriver.firefox.webdriver import WebDri开发者_如何学Pythonver
>>> driver = WebDriver()
Error: cannot open display: :0

How do I make this error go away?


Set up your SSH session to allow X11 forwarding, and run your client from an X windows session. On the server, the config /etc/ssh/sshd_config should have the line X11Forwarding yes. and your client side should have ForwardX11 yes. Then just to be sure invoke ssh with the -X option. The server side should have the program you want to run (firefox) installed.


Selenium webdriver is a remote control for a browser, for it to use firefox the machine must have a GUI, such as GNOME, running (eg you must be able to use firefox in the normal way on that machine). If you don't have a GUI try a headless browser such as HTMLUnitDriver instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消