Tag: selenium webdriver

无法使用Node.js中的Selenium Webdriver检索Chrome控制台的内容

我正在尝试使用node.js中的Selenium Webdriver来阅读Chrome控制台,但是到目前为止它并不成功。 没有错误。 但是它返回的是一个空数组[]。 以下是HTML和JavaScript函数的一个片段。 当在Chrome中手动运行时,这些写入控制台就好了。 <button name="button1" type="button" onclick="test_console()">Test</button> function test_console() { console.log("Hello World"); } 以下是我在node.js中使用的代码来尝试将输出传递给Chrome。 const webdriver = require('selenium-webdriver'); const chromeDriver = require('selenium-webdriver/chrome'); const logging = require('selenium-webdriver').logging; const path = require('chromeDriver').path; const service = new chromeDriver.ServiceBuilder(path).build(); chromeDriver.setDefaultService(service); const {By, Key} = webdriver; webdriver.promise.USE_PROMISE_MANAGER = false; const CHROME_BIN_PATH = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'; const prefs […]

升级节点,但得到“SyntaxError:在严格模式下使用const”错误

我在Amazon Linux上运行以下版本的节点和npm … [myuser@mymachine ~]$ node –version v8.8.1 [myuser@mymachine ~]$ npm -v 5.4.2 通过安装我的seleniuv-webdriver模块后 npm install selenium-webdriver 我正在运行我的nodeJStesting,但得到以下错误 /home/jboss/node_modules/selenium-webdriver/index.js:25 const chrome = require('./chrome'); ^^^^^ SyntaxError: Use of const in strict mode. at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/jboss/.jenkins/workspace/myco/automated-tests/nodejs/js/js-FF/Optimus-FF.js:2:15) at Module._compile (module.js:456:26) […]

在量angular器中安装geckodriver时出错 – npm install –save geckodriver

我列出了当前安装在我的系统中的npm版本以及当我尝试安装geckodriver时出现的错误。我读了[npm module version] – [geckodriver version] 1.10.x – geckodriver 0.19.1在geckodriver npm site。我有1.10.1版本只安装。即使我安装时面临错误。也跑了webdriver的经理更新 ,unzipps的v0.19.1.zip C:\ Users \ crk> npm版本 {npm:'5.5.1', ares:'1.10.1-DEV', http_parser:'2.7.0', icu:​​'57.1', 模块:'48', 节点:'6.9.2', openssl:'1.0.2j', uv:'1.9.1', v8:'5.1.281.88', zlib:'1.2.8'} W:\ Wgn \ JS_UIAutomation> npm install – 保存geckodriver geckodriver@1.10.0 postinstall W:\ Wgn \ JS_UIAutomation \ node_modules \ geckodriver节点index.js 下载geckodriver … events.js:160扔呃; //未处理“错误”事件^ RequestError:在ClientRequest处连接ETIMEDOUT 192.30.253.113:443。 在ClientRequest.g(events.js:291:16)处的ClientRequest.emit(events(event.js:96:13))处的emitOne(events.js:96:13) (events.js:188:7)在TLSSocket.socketErrorListener(_http_client.js:310:9)上的emitOne(events.js:96:13) :内部/ […]

使用ElementArrayFinder.filter()和async / await

Webdriver的Control Flow启用时,我一直使用下面的函数来过滤元素数组: filterElementsByText (elemList, comparator, locator) { return elemList.filter((elem) => { let searchTarget = locator ? elem.element(locator) : elem return searchTarget.getText().then((text) => text === comparator) }) } 我现在试图迁移我的回购使用async / await需要closures控制stream。 这个转换大部分都是成功的,但是我在上面的函数中遇到了麻烦。 间歇性地,我看到这个错误: 失败:java.net.ConnectException:连接被拒绝:连接 我能够用我写的一个testing用例https://angularjs.org来重现这个问题,虽然它发生的频率比我自己的应用要高得多。 let todoList = element.all(by.repeater('todo in todoList.todos')) let todoText = element(by.model('todoList.todoText')) let todoSubmit = element(by.css('[value="add"]')) let addItem = async (itemLabel = 'write […]

如何在Node中为WebDriverJS注册error handling程序?

按照文档中的说明尝试注册error handling程序时,出现错误: 注册一个事件侦听器,以便在有未处理的错误时得到通知。 webdriver.promise.Application。 的getInstance()。 on('uncaughtException',function(e){console.error('有一个未捕获的exception:'+ e.message);}); TypeError: Cannot call method 'getInstance' of undefined 什么是注册error handling程序的正确方法?

nodejs中的selenium-webdriver不返回当前标题

我正在通过selenium驱动程序的例子,它没有工作。 几个月前,它工作得很好,所以我想知道如果我做错了什么,或者如果testing方法已经改变。 var assert = require('assert'), test = require('selenium-webdriver/testing'), webdriver = require('selenium-webdriver'); var By = webdriver.By; test.describe('Google Search', function() { test.it('should work', function(done) { var driver = new webdriver.Builder(). withCapabilities(webdriver.Capabilities.chrome()). build(); driver.get("http://www.google.com"); driver.findElement(By.name("q")).sendKeys("webdriver"); driver.findElement(By.name("btnG")).click(); driver.getTitle().then(function(title) { assert.equal("webdriver – Google Search", title); done(); }); driver.quit(); }); }); 输出是: AssertionError: "webdriver – Google Search" == "Google" Expected […]

在selenium-webdriver.jstesting中获取testing标题和状态

我正在用selenium-webdriver.js写摩卡testing,并且只在当前testing失败的情况下尝试截图。 在摩卡,我可以得到当前的testing信息,如标题和状态,如下所示: afterEach(function(){ console.log('afterEach', this.currentTest.title, this.currentTest.state); }); 但是,selenium-webdriver.js使用selenium-webdriver / testing封装了Mocha的接口,原来的这个currentTest不再暴露: var test = require('selenium-webdriver/testing'); test.afterEach(function(){ //console.log('afterEach', this.currentTest.title, this.currentTest.state); }); 我想知道这样的信息是否仍然暴露出来或有任何解决方法。

节点Selenium WebdriverJS – 如何检查元素是否真正可点击?

如何检查一个元素是否真的在seleniumwebdriverJS点击? 我知道我可以检查元素是否显示,是否启用元素。 但是,如果该元素被其他元素隐藏,例如通过模式popup,则不能被点击。 在这种情况下,我希望webdriver等待,直到元素是真正可点击的。 这个怎么做? 谢谢您的帮助

在Selenium ChromeDriver中禁用图像

有没有办法使用Javascript(Node.js)禁用Chromedriver中的图像? 我找不到任何地方这个问题的正确答案!

WebDriverJs的getPageSource给了我一个对象,而不是页面的源代码

当我尝试显示页面的源时, res.json返回空白。 Selenium日志显示源代码已被检索。 任何想法如何才能正确接收更新的页面源代码? 它返回相同的东西,如果我使用其他function,如获取当前url。 码: var driver = new webdriver.Builder().usingServer('http://localhost:4444/wd/hub').withCapabilities(webdriver.Capabilities.firefox()).build(); driver.get('http://www.google.com'); var source = driver.getPageSource(); console.log(source); res.json({ message: source }); console.log输出: [{ then: [Function: then], cancel: [Function: cancel], isPending: [Function: isPending] } selenium日志: 16:17:30.273 INFO – Executing: [new session: Capabilities [{browserName=firefox}]]) 16:17:30.286 INFO – Creating a new session for Capabilities [{browserName=firefox}] 16:17:39.751 INFO – […]