本文将带您了解关于javascript–Webdriverio黄瓜不能使用承诺的新内容,同时我们还将为您解释黄瓜不能识别小程序的相关知识,另外,我们还将为您提供关于java–WebDriver:exe
本文将带您了解关于javascript – Webdriverio黄瓜不能使用承诺的新内容,同时我们还将为您解释黄瓜不能识别小程序的相关知识,另外,我们还将为您提供关于java – WebDriver:executeScript()导致BindException、javascript – jquery .not()不能使用live()、javascript – Selenium WebDriver点击隐藏元素、javascript – WebDriverJs的资源?的实用信息。
本文目录一览:- javascript – Webdriverio黄瓜不能使用承诺(黄瓜不能识别小程序)
- java – WebDriver:executeScript()导致BindException
- javascript – jquery .not()不能使用live()
- javascript – Selenium WebDriver点击隐藏元素
- javascript – WebDriverJs的资源?
javascript – Webdriverio黄瓜不能使用承诺(黄瓜不能识别小程序)
实际上,我想介绍这个简单的功能:
Feature: Example Feature In order to become productive As a test automation engineer I want to understand the basics of cucumber Scenario: My First Test Scenario Given I have open "https://google.com" Then the title should be "Google". And the bar should be empty.
通过这个测试:
const assert = require('assert'); module.exports = function() { this.Given(/^I have open "([^"]*)"$/,function(arg1,callback) { browser .url(arg1) .call(callback); }); this.Then(/^the title should be "([^"]*)"\.$/,callback) { // First solution const title = browser.getTitle(); assert(title,arg1); // Second solution browser .getTitle() .then(title2 => { assert(title2,arg1); callback(); }); }); this.Then(/^the bar should be empty\.$/,function(callback) { // Write code here that turns the phrase above into concrete actions callback(null,'pending'); }); }
我的配置文件:
"use strict"; const WebDriverIO = require('webdriverio'); const browser = WebDriverIO.remote({ baseUrl: 'https://google.com',// Or other url,e.g. localhost:3000 host: 'localhost',// Or any other IP for Selenium Standalone port: 4444,waitforTimeout: 120 * 1000,logLevel: 'silent',screenshotPath: `${__dirname}/documentation/screenshots/`,desiredCapabilities: { browserName: process.env.SELENIUM_broWSER || 'chrome',},}); global.browser = browser; module.exports = function() { this.registerHandler('BeforeFeatures',function(event,done) { browser.init().call(done); }); this.registerHandler('AfterFeatures',done) { browser.end().call(done); }); };
我的问题
我的问题是:
>我从未传入.call(回调)函数
>如果我通过在.url(arg1)之后添加callback()来绕过前一点,我会转到下一个点
>在第一个然后,第一个解决方案和第二个解决方案似乎都不起作用.当我试图记录const标题值时,我有一个未决的承诺.但是,当我试图解决这个承诺(第二种情况)时,我从不记录任何事情(即使在拒绝的情况下).
约束
>我不想使用wdio
>我使用的是硒2.53
>我使用的是cucumberjs 1.3.1
>我使用的是webdriverio 4.4.0
>我使用的是Nodejs v4.6.0
编辑:我总是有超时问题
解决方法
java – WebDriver:executeScript()导致BindException
在通过WebDriver加载的每个页面上运行((JavascriptExecutor)驱动程序).executeScript(javascripthere)时,
测试运行3分钟后,我收到以下错误:
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.BindException: Address already in use: connect System info: os.name: 'Windows XP',os.arch: 'x86',os.version: '5.1',java.version: '1.6.0_18' Driver info: driver.version: remote at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java: 341) at org.openqa.selenium.firefox.FirefoxDriver.execute(FirefoxDriver.java: 234) at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java: 173) at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java: 231) at org.openqa.selenium.By$6.findElements(By.java:200) at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java: 158) Caused by: java.net.BindException: Address already in use: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(UnkNown Source) at java.net.PlainSocketImpl.connectToAddress(UnkNown Source) at java.net.PlainSocketImpl.connect(UnkNown Source) at java.net.socksSocketImpl.connect(UnkNown Source) at java.net.socket.connect(UnkNown Source) at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java: 123) at org.apache.http.impl.conn.DefaultClientConnectionoperator.openConnection(DefaultClientConnectionoperator.java: 133) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java: 149) at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java: 108) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java: 415) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java: 641) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java: 211) at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java: 125) at org.openqa.selenium.firefox.FirefoxDriver $LazyCommandExecutor.execute(FirefoxDriver.java:341) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java: 328) ... 11 more
基本上,这样做的目的是捕获text()xpath语法无法选择的文本节点. Javascript使用< ddb>包装break标记之前和之后的文本节点.标签.然后,WebDriver可以使用/ ddb作为xpath语法来获取文本.
事情似乎运行顺利但在3分钟后崩溃并出现BindException错误.似乎我之前的问题中的Javascript导致了太多的出站连接.
我需要一个解决方案,允许Javascript在WebDriver中不断编辑DOM,以便FirefoxDriver可以选择文本节点.
解决方法
问题:http://code.google.com/p/selenium/issues/detail?id=923
修复:http://code.google.com/p/selenium/source/detail?r=10082
javascript – jquery .not()不能使用live()
我在一个页面中添加了一些带有ajax的dom,我试图通过.not()排除选择的结果,但它不适用于我.
这是一个简单的例子:
HTML:
<div>
<span>Some title</span>
<span><a href="Edit link">Edit</a></span>
<span><a href="#trashit" rel="trash">Trash</a></span>
<span><a href="#liveit" rel="publish">Live</a></span>
<span><a href="#draftit" rel="draft">Draft</a></span>
</div>
jQuery的:
jQuery('.list-item span a').not('.list-item span.edit a').live('click', function(){
//do stuff
});
观察:
>如果我删除代码的.not()部分,选择适用于live().
>如果我使用.not()但用click()替换live()代码可以正常工作.
但我需要使用live()运行.not()(不包括.edit类); (包括带有ajax的dom)
提前致谢!
解决方法:
按照the .live()
docs:
DOM traversal methods are not supported for finding elements to send to
.live()
. Rather, the.live()
method should always be called directly after a selector, as in the example above.
因此,将类排除添加到选择器:
jQuery('.list-item span:not(.edit) a').live('click', function(){
//do stuff
});
javascript – Selenium WebDriver点击隐藏元素
我知道用硒1我可以这样做如下:
selenium.click(id="idOfHiddenField");
并且这将工作,但是与硒2(WebDriver),这不是.我不想使用jquery来启用或显示隐藏的字段或JavaScript.这是因为大多数测试都在使用xpath.
或者我只需要留下旧的硒,让你点击隐藏的领域?
解决方法
例如:
document.getElementsByClassName('post-tag')[0].click();
上述JavaScript将点击此页面右上方的“Selenium”标签(旁边的问题),即使它被隐藏(假设).
所有你需要做的是通过JavascriptExecutor接口发出这个JS指令,如下所示:
(JavascriptExecutor(webdriver)).executeScript("document.getElementsByClassName('post-tag')[0].click();");
这将使用JS沙箱和综合点击事件来执行点击操作.虽然它破坏了WebDriver用户活动模拟的目的,但是您可以将其用于您的情况下,在您的情况下很好的效果.
javascript – WebDriverJs的资源?
我知道有以下资源:
http://docs.seleniumhq.org/docs/03_webdriver.jsp
https://code.google.com/p/selenium/wiki/WebDriverJs
但我想知道是否有一个网站拥有WebDriverJs的整个API.我在哪里可以找到可用的方法和要发送的特定参数?
类似的东西:http://rubydoc.info/gems/watir-webdriver/frames
https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js
关于javascript – Webdriverio黄瓜不能使用承诺和黄瓜不能识别小程序的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于java – WebDriver:executeScript()导致BindException、javascript – jquery .not()不能使用live()、javascript – Selenium WebDriver点击隐藏元素、javascript – WebDriverJs的资源?的相关信息,请在本站寻找。
本文标签: