Tag: ghostdriver

使用java运行ghostdriver会出错

我正在使用远程ubuntu机器来运行我的测试用例。 我有jenkins配置github。 我可以使用我的windows7机器使用putty.exe访问这台机器。 我想使用phantomjs运行无头测试用例(调度作业),即当我的Windows机器关闭时,测试将在远程ubuntu机器上运行,该机器始终打开。 现在的问题是,当我现在构建它会给出错误: Caused by org.openqa.selenium.HasInputDevices … … 我的setup()方法和pom看起来像: 建立() DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,”/usr/bin/phantomjs”); driver = new PhantomJSDriver(caps); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get(Production); 的pom.xml com.github.detro.ghostdriver phantomjsdriver 1.0.3 编辑:已通过添加selenium 2.34.0 jar依赖项解决了HasInputDevices的问题 但是在运行上面测试时仍然会出错: 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: […]

Java PhantomJSDriver禁用控制台中的所有日志

我正在使用Selenium开发一个小型控制台应用程序,我需要关闭它的所有日志。 我试过了phantomJSDriver.setLogLevel(Level.OFF); 但它不起作用。 我需要帮助。 如何禁用使用Selenium和Phantomjs(GhostDriver)的控制台应用程序中的所有日志?

Selenium GhostDriver / PhantomJS:使用sendKeys()/ Javascript无法上传文件

我正在使用PhantomJSDriver / GhostDriver运行无头脚本,并尝试在编写电子邮件时上传gmail上的文件。 工具:Selenium与PhantomJS / GhostDriver。 html代码如下: Click the “Browse” button to select a file. Click “Done” when you’re finished. 1. 2. 3. 4. 到目前为止,我已经尝试了以下两种方法来上传文件,但它们都没有工作: 使用Javascript: wait.until(ExpectedConditions.presenceOfElementLocated(By.name(“file1”))); WebElement btnChoseFile = driver.findElement(By.name(“file1”)); System.out.println(btnChoseFile.isEnabled()); File file = new File(“attachments/Alan Morales.doc”); String script = “document.getElementsByName(\”file1\”)[0].value='” + file.getAbsolutePath() + “‘;”; jsexec.executeScript(script); System.out.println(“File attached…..”); 收到的例外情况: Exception in thread “main” org.openqa.selenium.ElementNotVisibleException: […]

在Selenium Grid中注册PhantomJS节点时出错

我有以下问题 我成功推出了Selenium Grid hub: java -jar selenium-server-standalone-2.53.0.jar -role hub 之后我尝试使用以下命令启动PhantomJS节点: phantomjs –webdriver=8090 –webdriver-selenium-grid-hub=http://localhost:4444 但得到了错误: [INFO – 2016-03-25T13:56:28.397Z] GhostDriver – Main – 在端口8090上运行[INFO – 2016-03-25T13:56:28.397Z] GhostDriver – Main – 注册到Selenium HUB’http :// localhost :4444 ‘版本:使用’127.0.0.1:8090’与org.openqa.grid.selenium.proxy.DefaultRemoteProxy作为远程代理。 [ERROR – 2016-03-25T13:56:28.400Z] GhostDriver – main.fail – {“line”:97,“sourceURL”:“phantomjs://platform/hub_register.js”,“stack”:“register @” phantomjs://platform/hub_register.js:97:79 \ nglobal code @ phantomjs://code/main.js:78:37“} phantomjs://platform/console++.js:263错误 标准节点工作正常,但PhantomJS错误。 我做错了什么?

使用GhostDriver时如何设置屏幕/窗口大小

我在基于Java的项目中使用GhostDriver作为WebDriver实现。 我想拍摄页面的快照。 默认页面大小有点笨拙,所以我想控制快照的页面大小。 但是,我找不到谷歌的任何例子。 那么,有人可以告诉我怎么样? 非常感谢你。

如何使用java运行Selenium的ghostdriver

我想使用phantomJS进行一些网络测试,我遇到了GhostDriver ( https://github.com/detro/ghostdriver )。 我使用自述文件中的说明构建它,我可以在指定的端口上运行它,但我不知道如何从我的Java代码访问Web驱动程序。 为了澄清,我在ruby中看到了这个例子: caps = { :browserName => “phantomjs”, :platform => “LINUX” } urlhub = “http://key:secret@hub.testingbot.com:4444/wd/hub” client = Selenium::WebDriver::Remote::Http::Default.new client.timeout = 120 @webdriver = Selenium::WebDriver.for :remote, :url => urlhub, :desired_capabilities => caps, :http_client => client @webdriver.navigate.to “http://www.google.com/” puts @webdriver.title @webdriver.save_screenshot(“./screenshot.png”) @webdriver.quit 我只是不确定如何从java做同样的事情。