密码
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.io.File;
import java.util.HashMap;
public class tttt {
public static void main(String[] args) throws InterruptedException {
ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromePrefs = new HashMap<>();
//mePrefs.put("download.default_directory", new File(RobotPay.class.getClassLoader().getResource("alipaycaptchatmp/").getFile()).getAbsolutePath());
chromePrefs.put("download.prompt_for_download", false);
chromePrefs.put("download.directory_upgrade", true);
chromePrefs.put("safebrowsing.enabled",true);
chromePrefs.put("profile.managed_default_content_settings.images", 2);//禁图片
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("--headless");
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
System.setProperty("webdriver.chrome.driver", args[0]);
options.setBinary(args[1]);
ChromeDriver dr = new ChromeDriver(options);
}
}
错误:
[qateadmin@UAT13352 ~]$ java -cp "/opt/tars/apps/100018485/releases/762245/WEB-INF/lib/*:./" tttt /opt/tars/apps/100018485/releases/762245/WEB-INF/classes/seleniumdriver/chromedriver /usr/bin/google-chrome
Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5) on port 4461
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'UAT13352', ip: '10.5.117.188', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.4.5.el7.x86_64', java.version: '1.7.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
at tttt.main(tttt.java:25)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:171)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 7 more
Chrome版本:
[qateadmin@UAT13352 ~]$ google-chrome -version
Google Chrome 71.0.3578.98
chrome可执行模式为777
chromedriver版本:2.45
(支持ChromeV70-72,模式为777
)
操作系统:centos_x64
此外,我在本地Ubuntu16.04_x64和CentOS7_x6虚拟机上测试了它,没有例外。我被这个问题难住了,有什么建议吗?
更新
将java升级到java SE 8u191
后,错误消息如下:
[qateadmin@UAT13352 ~]$ java -cp "/opt/tars/apps/100018485/releases/762245/WEB-INF/lib/*:./" tttt /opt/tars/apps/100018485/releases/762245/WEB-INF/classes/seleniumdriver/chromedriver /usr/bin/google-chrome
Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5) on port 3602
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'UAT13352', ip: '10.5.117.188', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.4.5.el7.x86_64', java.version: '1.8.0_191'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
at tttt.main(tttt.java:25)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:171)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 7 more
此错误消息...
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'UAT13352', ip: '10.5.117.188', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.4.5.el7.x86_64', java.version: '1.7.0_51'
.
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
…意味着ChromeDriver无法启动/生成新的Web浏览器,即Chrome浏览器会话。
您的主要问题是您使用的二进制文件版本之间的不兼容性,如下所示:
所以JDK v7u51、Selenium客户端v2.53.1、ChromeDriver v2.45和谷歌Chrome 71.0.3578.98之间存在明显的不匹配。
@Test
。我的selenium代码没有运行。不断向我抛出以下错误: FIREFOX版本:53.0.3(32位)SELENIUM版本:selenium-java-3.4.0我正在使用Eclipse Luna,我的机器是Windows 7(64位)。我已经阅读了所有的帮助查询,但找不到解决方案。这是我的Java代码:
打开新驱动程序窗口时出错: 服务器日志: 我在linux上运行以下代码: 我的集线器节点已经启动并运行。那为什么我得到这个错误。
在使用docker-compose在网格上动态执行我的套件时,我得到了以下异常stacktrac: 这是在执行以下操作时发生的: chrome也是如此。我最近将selenium升级到最新版本,即3.141.59。 是: 这在Jenkins和我从cmd在我的系统中执行时都发生了。我不确定这个问题是与selenium还是网络有关。如果有其他解决方案的链接,请在此分享。预先感谢任何帮助。 更新和编辑:
问题内容: 我的selenium代码未运行。不断向我抛出以下错误: FIREFOX版本:53.0.3(32位)SELENIUM版本:selenium-java-3.4.0我正在使用Eclipse Luna,并且我的机器是Windows 7(64位)。我已经阅读了所有帮助查询,但找不到解决方案。这是我的Java代码: 问题答案: 您必须在代码中考虑几个因素,如下所示: 您已通过创建的相同类的对象,并
我正在尝试使用Selenium Grid运行一个简单的程序(事先不了解Selenium Grid),出现如下错误: 线程“main”org.openqa.selenium.remote中出现异常。UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。构建信息:版本:“未知”,版本:“未知”,时间:“未知”系统信息:主机:“DEL1-
我是硒的新手。能够在Ubuntu上配置selenium设置。配置详情如下: 谷歌浏览器68.0.3440.84 但每次跑步我都会发现詹金斯的错误: 请推荐我。