我有redhat Linux服务器命令行,但没有GUI,我需要在这个服务器上使用firefox运行selenium代码。因为我是硒的新手,所以我不确定它是否会起作用。
为了达到这个目的,我成功地在我的Redhat linux机器上安装了Firefox,但由于显示没有找到显示器,因此无法触发它。
还有其他任何方法可以实现无头浏览,其中几乎可以打开一个firefox并且可以在没有GUI的情况下执行selenium代码。有可能吗??
答案 0 :(得分:2)
您可以使用HtmlUnitDriver
selenium来使用无头浏览,但它不会打开firefox并且可能无法将所有内容加载到它的缓存中,与firefox一样
参考下文: -
https://code.google.com/p/selenium/wiki/HtmlUnitDriver
你可以使用的另一件事是Phantomjs和selenium Webdriver。这是大多数行业用于无头浏览的模式
请参阅以下内容: -
http://www.guru99.com/selenium-with-htmlunit-driver-phantomjs.html
是的,您可以使用命令行
触发selenium文件http://www.tutorialspoint.com/testng/testng_executing_tests.htm
Bash file is running fine in windows for testng but it is not working in linux/mac
现在如果你的firefox还没有打开,那么你的操作系统基本上是firefox的一些设置问题
也请参考: -
https://serverfault.com/questions/279036/open-terminal-via-ssh-run-firefox-display-not-found
你可能在红帽的某些许可中遇到问题
希望它会对你有所帮助:)。