Tag: selenium

使用Appium,Seleniumnetworking驱动程序,Node js,Mocha等select不在原生android应用程序的屏幕上的UI元素

我正在testing一个原生的Android应用程序,并需要点击屏幕底部的button。 我已经看到了很多使用Java和Javascript的例子,但我使用Node.js,似乎没有任何工作。 我对这个东西很新,在这么简单的事情上浪费了太多的时间。 例如,点击一个屏幕上的元素,这个工作: it("Select Button Test",function(){ return driver .setImplicitWaitTimeout(timeoutWait) .elementByXPath('//android.widget.TextView[@text=\'My Button\']').click(); }); 此外,完整的xpath适用于屏幕上的元素 – 在这种情况下: var myButton ='//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.TableLayout[1]/android.widget.TableRow[10]'); it("Select Button Test",function(){ return driver .setImplicitWaitTimeout(timeoutWait) .elementByXPath(myButton).click(); }); 通过在testing运行时滚动到该button,并在appium检查器中启动屏幕,我find了该button的完整xpath。 我已经尝试了各种滚动,触摸,并从networking驱动器文档的刷卡方法,但没有什么是显而易见的,我已经离开了蓬松… 那么如何访问不在屏幕上的button呢? 我敢肯定它的一些世俗的细节。 谢谢!

域在主机上parsing,但不在docker容器内

我有两个容器,一个运行启动量angular器的Node.js进程,另一个运行独立的Selenium容器。 该文件如下所示: version: '2' services: www.example.localhost: build: . depends_on: – selenium dns_search: – static.example.localhost extra_hosts: – "static.example.localhost:127.0.0.1" ports: – "3000:3000" – "4000:4000" volumes: – ./src:/code/src – ./api:/code/api entrypoint: "npm run" command: "test:e2e" selenium: dns_search: – selenium.example.localhost image: selenium/standalone-chrome-debug:2.52.0 environment: no_proxy: localhost volumes: – /dev/urandom:/dev/random ports: – "4444:4444" – "6900:5900" www.example.localhost运行量angular器,然后通过protractor.config.js中的这些行连接到selenium容器: seleniumAddress: "http://selenium:4444/wd/hub", directConnect: false, 当我在Selenium容器上运行VNC时,打开容器中的chrome浏览器并键入www.example.localhost:3000它无法parsing域。 […]

如何编写在Browserstack上运行量angular器/ Selenium浏览器自动化脚本的AWS Lambda脚本?

我非常享受AWS Lambdafunction,而且我想知道我想在这里做什么是可能的。 在我的本地机器上,我有一个量angular器configuration文件: // conf.js exports.config = { framework: 'jasmine', seleniumAddress: 'http://127.0.0.1:4444/wd/hub', specs: ['automation-script.js'], capabilities: { browserName: 'chrome' } } 和一个脚本,加载一个浏览器窗口与一个特定的url: describe('Protractor Demo App', function() { it('should have a title', function() { browser.driver.get('https://github.com/'); // Click around and do things here. }); }); 我的脚本现在的目的不是对正在开发的应用程序进行黑盒testing,而是使我不想做的常见浏览器任务自动化。 目前,我通过我的本地命令行像这样运行量angular器脚本: protractor protractor.conf.js 我想知道是否可以从另一个node.js脚本中运行量angular器。 我的想法是,我可以使用Lambda函数启动量angular器作业,可能通过使用Browserstack或Sauce Labs提供的浏览器,但我无法弄清楚如何从Node.js脚本运行量angular器。

差异protractor.controlFlow().exec和browser.call()

我知道要将一个自定义函数插入到量angular器控制stream程中,您可以使用protractor.controlFlow()。execute,如下所示: protractor.promise.controlFlow().execute(function() { return getData().then(function(my_data) { return my_data.some_process(); }); }); 但是,似乎我可以使用browser.call()方法做同样的事情: browser.call(function() { return getData().then(function(my_data) { return my_data.some_process(); }); }); 据我所知,browser.call是webdriver控制stream的包装,protractor.controlFlow()与量angular器本身具有类似的function。 两者都回报“承诺”,所以他们似乎在做同样的事情。 两种方法是可以互换的吗? 如果不是的话,我什么时候该用这个或那个。

酱实验室量angular器,格式不正确的URI

我的量angular器configuration是: exports.config = { baseUrl: 'http://www.onet.pl', directConnect: false, sauceUser: 'myuser', sauceKey: 'mypassword', capabilities: { 'browserName': 'chrome', 'chromeOptions': { 'args': ['show-fps-counter=true', '–allow-running-insecure-content'] } }, } 当我尝试启动testing时,出现以下错误: [12:57:56] I/sauce – Using SauceLabs selenium server at http://ondemand.saucelabs.com:80/wd/hub [12:57:56] I/launcher – Running 1 instances of WebDriver [12:57:56] E/launcher – URI malformed [12:57:56] E/launcher – URIError: URI malformed at decodeURIComponent […]

Selenium Webdriver Node.js:如何加载和执行jQuery代码

我使用Selenium webdriver&Node.JS进行functiontesting。 我试图使用jQuery代码做一些处理。 首先,我试图包括jquery并加载它: driver.executeScript(“var s = window.document.createElement('script'); \ s.src =' https: //cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js '; \ window.document.head.appendChild(s);“); – > 这个治疗似乎被执行(因为我没有捕捉到相关的错误) 但是,当试图使用jQuery的function,这里是一个例子: driver.executeScript( “$( '#编辑提交')上( '点击',函数(){警报( 'testing');})”); 我正在抓住这个: 我的error handling程序… WebDriverError:未知错误:$不是一个函数 似乎jquery要么没有成功加载,或者我没有正确使用它。 build议?

Selenium:服务器以状态127结束

我看了很多其他的post,似乎没有为我工作,即使它给出了同样的错误。 我通过Windows运行bash,所有我想要做的是从npm selenium-webdrivers获取给定的代码加载,甚至不工作。 这是app.js: require('chromedriver'); const webdriver = require('selenium-webdriver'), By = webdriver.By, until = webdriver.until; var driver = new webdriver.Builder() .forBrowser('chrome') .build(); driver.get('http://www.google.com/ncr'); driver.findElement(By.name('q')).sendKeys('webdriver'); driver.findElement(By.name('btnG')).click(); driver.wait(until.titleIs('webdriver – Google Search'), 1000); driver.quit(); 这里是我运行节点app.js 这里的Bash错误 任何帮助,将不胜感激

NightWatch – 无法在具有值的input上find具有xpath定位器的元素

随着守夜,我有问题,我的网页上find一个元素,XPATH是好的,因为我已经find它与FirePath。 我的页码: <label class="switch " data-ng-repeat="item in values"> <input class="ng-pristine ng-untouched ng-invalid ng-invalid-required" name="obtentionPermisConduiteAccompagneeSwitcher" value="N" ng- model="$parent.model" ng-required="!$parent.model" required="required" type="radio"/> …… 我的select器: input_conduiteAccompagnee: { selector: './/input[@name="obtentionPermisConduiteAccompagneeSwitcher" and @value="N"]', locateStrategy: 'xpath' }, 我的命令: //conduite accompagnee onglet_conducteur.waitForElementVisible('@input_conduiteAccompagnee', 10000); onglet_conducteur.click('@input_conduiteAccompagnee'); browser.pause(3000); 但是我有这个信息: ×等待元素在10000毫秒内可见时超时。 – 预计“可见”,但得到:“不可见” 你有没有同样的问题?

NodeJS软件包处理并行无头testing的Linux盒子(ES)与selenium网格的function?

我需要处理authentication的多个用户在selenium独立服务器上运行并行testing,并在nodejs上发现了两个webdriver客户端。 有webdriver-js和wd-js 。 哪个更积极可靠? 任何经验? 我有点担心他们在节点或selenium更新或删除function时发生故障。 我不认为任何这些软件包会提及自动启动Xvfb在每个testing独特的显示编号。 那么在驱动浏览器之前启动shell命令来运行xvfb? 下面的过程就是我试图在nodejs中构build的(它本质上类似于Grid 2,但是在nodejs上持续集成testing运行的目的)并寻找下面任何部分的任何包或者build议。 1)首先使用持久的双向连接(WebSockets或HTTP 1.1)对用户进行身份validation, 2)请求由用户在可用的硬件节点上运行的启动/队列testing(我将添加更多的Linux盒子,因此需要一个包来在“网格”上分布并行testing) 3)监视正在运行的selenium浏览器testing并发送客户端状态更新(ex)运行/停止) 4)用户提交的testing需要持久性和可访问性,以便将来或持续集成(couchdb或mysql) 5)安排连续运行的作业(例如每隔一段时间运行一次)。 nodejs有点矫枉过正? 我应该只专注于Java的背面吗?

selenium webdriver getText返回

我有一个selenium脚本,应该从包含所需值的单元格后的表格列中获取文本。 我有脚本工作,但由于某种原因,当我运行getText(),并检查返回的值我得到[对象对象]在我的node.js控制台…我很困惑我试图parsing它为一个string,我已经调用了该variables的getText()将是元素和其他几种方式,但无济于事… 这里是我的脚本部分: if(tempID!=1){ //tr[contains(td[1], "ID#")]/td[#] scrapeArray[0] = tempID; console.log(scrapeArray[0]); } }).then(function(){ scrapeArray[1] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[2]')).text()); console.log("1: "+scrapeArray[1]); }).then(function(){ scrapeArray[2] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[3]')).text()); console.log("2: "+scrapeArray[2]); }).then(function(){ scrapeArray[3] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[4]')).text()); console.log("3: "+scrapeArray[3]); }).then(function(){ scrapeArray[4] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[5]')).text()); console.log("4: "+scrapeArray[4]); }).then(function(){ scrapeArray[5] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[6]')).text()); console.log("5: "+scrapeArray[5]); }).then(function(){ scrapeArray[6] = String(driver.findElement(webdriver.By.xpath('//tr[contains(td[1], "'+tempID+'")]/td[7]')).text()); console.log("6: "+scrapeArray[6]); }).then(function(){ numberOf++; […]