【windows7 selenium2+java 搭建】教程文章相关的互联网学习教程文章

java-在没有GUI的情况下在Selenium上运行ChromeDriver或FirefoxDriver(无头模式)【代码】

JAVA(硒代码段):manageDriver();WebDriver driver = new ChromeDriver();driver.get(url);driver.manage().timeouts().implicitlyWait(3+r, TimeUnit.SECONDS);这足以创建一个ChromeDriver窗口,这对我的客户来说非常烦人.有没有一种方法可以使ChromeDriver在没有GUI的情况下运行? 编辑:我看过xvfb,不确定是什么.我可以用它使我的firefoxDriver或chromeDriver无头吗?解决方法:您需要一个X服务器.跟着这些步骤:安装xvfb:sudo a...

java-如何单击Robot Framework Selenium中的元素【代码】

如何使用Selenium2Library为测试用例编写关键字,以单击没有元素ID的按钮? 以下是html代码.我是硒新手!<a href="redirect.cfm?app=profile"> <div id="profile" class="icon"> <img style="display:block; margin:0 auto;" src="assets/images/profile.png"> <h3>Profile</h3> </div> </a>我试过了driver.findElement(By.Xpath("//img[@src='assets/images/profile.png']")).click();但是得到了错误:LoginTest| FAIL | ValueErro...

Selenium with Java-无法创建下拉循环【代码】

我无法通过所选项目的定位器选择下一个下拉项目.我的目的是通过下拉菜单测试网站是否支持其他语言.发送键盘向下箭头可激活下拉菜单中的滚动条.有人可以帮忙吗?driver.findElement(By.xpath(".//*[@id='trigger']/div/paper-input/paper-input-container")).click();Thread.sleep(1000);driver.findElement(By.xpath(".//*[@id='langList']//paper-item//.[@tabindex=\"0\"]")).click();Thread.sleep(1000);driver.findElement(By....

java-如何使用Selenium从表中获取所有元素【代码】

我不知道为什么我只得到一个< tr>元件.我搜索我的桌子WebElement tableProducts = driver.findElement(By.id("gridAvailableProducts"));那么我想找到所有< tr>元素List<WebElement> tableRows = tableProducts.findElements(By.tagName("tr"));但是当我检查tableRows大小时,我得到1.我没有得到它,因为我更早地使用了此示例代码,并且工作正常.这是我的HTML:<table id="gridAvailableProducts"> <thead> <tr id="gridProductsHead"...

java-使用Selenium WebDriver运行TOR浏览器【代码】

我目前正在尝试使用Selenium WebDriver(JAVA)2.53和Firefox 43.0执行TOR 6.0.4.我已经按照这篇文章Using Selenium WebDriver with Tor的说明进行操作,但是将TOR的profilePath加载到Firefox Binary时出现错误.我已经看到可以通过将TOR profile.default存档加载到firefox binaty中来吃午饭,但是当我用该配置文件实例化二进制文件时,我得到了一个驱动程序信息:driver.version:未知.我一直尝试更改Firefox版本.在启动驱动程序的代码下...

Java+selenium+testng【图】

1,总结一下自己的UI自动化和接口自动化项目的框架,主要是UI自动化,UI自动化完成了37个城市的3个网站(链家,贝壳,房天下)的房屋信息的收集,和测试系统的房屋数据的比较。接口只完成了2个接口。 首先:看一下项目的整体框架 分为这5个部分 其中src/test/java主要干活的,是主项目,src/test/resource是测试数据,target是测试输出, pom文件是管理依赖包等等,xml文件是运行测试的。 先看下src/test/java 其中红色的部分...

java-如何确定Selenium是否存在WebElement?【代码】

我知道我可以使用(driver.findElements(By.xpath(“ Xpath Value”)).size()!= 0); 但是,我使用的是页面对象模型,其全部目的是在单独的类中预定义WebElement,因此不必在测试类中使用“ FindElements By”. 这是我目前拥有的if (objPage.webElement.isEnabled()){System.out.println("found element"); }else{System.out.println("element not found"); }但是,这试图识别可能不存在的WebElement.当它不存在时,我得到:No Such Elem...

java-Selenium无法在找到的元素中发送密钥【代码】

我的这个externalHtml有一个元素-<input class="inp-text ps-component ng-valid-maxlength ng-touched ng-pristine ng-empty ng-invalid ng-invalid-required" ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 200, 'blur': 0 } }" required="required" maxlength="100" ng-model="model.name"/>我曾尝试-driver.findElement(By.cssSelector("input"));可以找到这个元素,但是当我尝试做driver.findElement...

WebDriverWait.until在Selenium-java-3.2和Selenium-java-3.3版本中不再可用【代码】

在Selenium-java-3.0.1中,我可以使用WebDriverWait.until进行显式等待:new WebDriverWait(myChromeDriver, 30).until((ExpectedCondition<Boolean>) wd -> ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));上面的代码在Selenium-java-3.0.1中运行良好,直到我们升级到Selenium-java-3.2,其中WebDriverWait类从client-combined-3.3.0-nodeps.jar一起消失了. Selenium 3.2 / 3.3中对应的...

Selenium(Java)从页面上显示的缩短中获取完整文本【代码】

我想获取链接的完整文本,该文本包含在页面元素中,并且可能是带有.getText()参数的值的检索.问题是,页面上仅显示部分内容,后跟“ …”..getText returns = "http://www.example.com/es_es/spa..." what I need to get ="http://www.example.com/es_es/spain/legal-notice.html"这是HTML <a href="http://www.example.com/es_es/spain/legal-notice.html" target="_blank">http://www.example.com/es_es/spa...</a> 我能够找到该元素...

java-使用sendKeys的消息“ org.openqa.selenium.InvalidSelectorException:无效选择器:无法使用XPath表达式定位元素”【代码】

我在尝试使用Selenium上传文件时遇到麻烦.由于浏览按钮没有输入标签,因此无法使用sendKeys()函数传递路径.它是用Angular编写的. 这是浏览按钮元素:<a id="attachmentUpload-browse0" name="attachmentUpload-browse0" ng-click="clickBrowse($index)" class="btn-pri" xpath="1"></a>我确实在源代码上方的代码下方找到了一个输入标签,但是尝试使用.sendKeys()时出现错误.<input type="file" id="attachmentUpload-file0" name="at...

如何在Java中使用Selenium提交表单【代码】

我正在使用Selenium WebDriver来自动化系统.语言是Java.我已经完成了大多数事情,但是我只停留在一点.我需要提交一个包含用户名,密码和重新输入密码字段的表格.但是当我填充它们(使用硒)并单击“创建帐户”按钮时,它不起作用.Here is the code,System.setProperty("webdriver.chrome.driver", "./ChromeDriver/chromedriver.exe");WebDriver driver = new ChromeDriver();driver.get("URL Here");WebElement element9 = driver.find...

java-Selenium-存储隐藏变量

我们正在使用Junit Selenium对我们的网页进行网络测试.但是我们遇到了一个问题. 我需要使用Selenium解析隐藏字段中的值.隐藏字段的HTML<输入type =“ hidden” name =“ secretId” value =“ 123456” />我使用以下XPath// input [@ name =’secretId’] / @ value 我需要抓取该隐藏变量,并使用XPath进行存储,然后在脚本中进一步使用它. 我该如何用硒呢? 我努力了 字符串secretId = selenium.getText(“ // input [@ name =’sec...

java-Selenium 2 WebDriver NoClassDefFoundErrorS【代码】

我正在Eclipse中使用Selenium 2 WebDriver,并且一切正常. 但是,当我想在没有Eclipse的情况下测试WebDriver测试用例时,会出现许多缺少的类. 首先,它以:NoClassDefFoundError com/google/common/collect/Maps所以我下载了guava.jar并为其设置了类路径. 但是现在出现了下一个NoClassDefFoundError:java.lang.NoClassDefFoundError: org/json/JSONException错误总是在createDriver()上发生; 我在Java中使用JUnit运行Selenium. “仅J...

IDEA+selenium3+火狐/谷歌驱动 JAVA初步环境搭建 笔记【代码】【图】

0 环境系统环境:win7 selenium驱动 谷歌浏览器以及驱动 火狐浏览器以及驱动1 驱动地址的下载 1.1 selenium jar包 https://www.seleniumhq.org/download/ 1.2 谷歌浏览器首先输入chrome://version/ 根据版本下载相对应的驱动 下面地址任选一个即可http://npm.taobao.org/mirrors/chromedriver/ http://chromedriver.storage.googleapis.com/index.html 1.3 火狐浏览器 https://ftp.mozilla.org/pub/firefox/releases/例如...