小编Jra*_*awr的帖子

Selenium FireFoxDriver 无法连接

我第一次尝试使用 Selenium 来驱动 Firefox。我使用几乎相同的代码来驱动 Chrome,没有出现任何问题。但是,当我尝试使用 Firefox 驱动程序时,浏览器打开、停止,然后在大约 60 秒后,我收到如下错误报告:

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox   console output:
4474-a285-3208198ce6fd}","syncGUID":"dcskEFBTLyBH","location":"app-global","version":"48.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1471881400240,"updateDate":1471881400240,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"48.0.1","maxVersion":"48.0.1"}],"targetPlatforms":[],"seen":true}
1472056603181   addons.xpi  DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
Run Code Online (Sandbox Code Playgroud)

我检查了其他指南,他们建议我更新我的 .jar 文件。我正在使用 selenium-java-3.0.0-beta2 和 Firefox 48.0.1 进行测试,以便我的文件是最新的。我想让它正常运行。

更新:代码仍然无法工作,我已经设置了系统属性来正确设置 geckodriver。但是,我仍然无法让驱动程序正常运行。它甚至不再启动浏览器。

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class SimpleFireFoxDriver {


public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver.exe");

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", true);

   WebDriver driver = new FirefoxDriver();

   driver.get("http://www.youtube.com");

   System.out.println("Made it to …
Run Code Online (Sandbox Code Playgroud)

java firefox selenium geckodriver

3
推荐指数
1
解决办法
1万
查看次数

Selenium 检查属性是否包含 java 中字符串的一部分

所以我有一个网页,其中某些元素的 Id 是动态生成的,某些部分会发生变化,某些部分会保持不变,如下所示:

<div id= "xxxdiv" title= 'this title'>
  <p id = "xxxp">
  <table id = "xxxtable" title = 'not derp'>
         <div id = "yyyydiv">
           <table id = "yyytable" title= 'derp'>
             <table id = "yyytable2" title = 'not derp'>
               <table id = "zzztable" title = derp>
Run Code Online (Sandbox Code Playgroud)

我正在尝试在页面上进行一些动态查找,以查找 id 包含已知值的给定元素。例如,我并不总是知道可能存在多少嵌套元素,因此最终生成的数字可能会有所不同。所以我想通过 xpath 找到一个元素,其中 @title = not derp 和 @id 包含 yyy。我怎样才能做到这一点?

java selenium xpath dom

3
推荐指数
1
解决办法
9731
查看次数

标签 统计

java ×2

selenium ×2

dom ×1

firefox ×1

geckodriver ×1

xpath ×1