标签: browser-automation

NodeJS应用程序中的功能自动化Code​​Coverage

我正在寻找一个工具的指针,可以帮助我确定nodeJs中的功能自动化覆盖.(这不是单元测试!).

我为NodeJS编写的前端应用程序运行了很多selenium自动化.但我想知道这些自动化的功能覆盖范围.

(我之前使用jacoco for java)

selenium automated-tests code-coverage browser-automation node.js

5
推荐指数
1
解决办法
1572
查看次数

使用 Actions.sendKeys() 还是 WebElement.sendKeys() 来模拟用户使用 Selenium WebDriver 键入是否更好?

据我所知,有两种使用 Selenium 打字的方法:

new Actions(webDriver).sendKeys("text to send").perform();
webElement.sendKeys("text to send");
Run Code Online (Sandbox Code Playgroud)

Actions方法似乎是复制用户键入的最自然的方式,因为按键被发送到浏览器想要的任何地方(我相信正在幕后使用名为 sendKeysToActiveElement 的方法)。然而,许多教程指导测试人员使用该WebElement方法(这实际上是使用 SafariDriver 时的唯一选择),我认为因为它更简单。

Actions方法实际上是更好地模拟用户交互,还是我应该WebElement为了方便而使用该方法?

selenium browser-automation selenium-webdriver

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

梦魇JS不工作

我知道问题的标题看起来很模糊!但就是这样.

我在生产服务器上安装了nodejs,其中phantomjs工作正常,然后我安装了恶梦npm install nightmare,我可以在node_modules中看到它,我尝试了github上开发人员列出的示例:

var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true })

nightmare
  .goto('http://yahoo.com')
  .type('input[title="Search"]', 'github nightmare')
  .click('#uh-search-button')
  .wait('#main')
  .evaluate(function () {
    return document.querySelector('#main .searchCenterMiddle li a').href
  })
  .end()
  .then(function (result) {
    console.log(result)
  })
Run Code Online (Sandbox Code Playgroud)

没有发生任何事情,脚本没有输出任何内容,我将脚本简化为简单的单一转到,对于我服务器上的页面,当我通过脚本运行脚本时从未调用过该页面 node file.js

我有CentOS 6.7,phantomjs 1.1我也在最新版本的phantomjs上进行了全新的CentOS 7安装测试,同样的事情.

我错过了某种先决条件还是什么?如何调试问题,因为node script.js没有提供任何输出

更新:显然问题是,电子,噩梦'而不是幻影'使用的电子需要图形环境,这就是它无法在我的环境中运行的原因.

javascript browser-automation node.js phantomjs nightmare

5
推荐指数
1
解决办法
6887
查看次数

使用VBA时,Form.Submit不会通过

我有一个网页,我正在从中提取数据.除了单击一个图像元素然后提交一个表单并创建一个带有数据的弹出窗口,我可以用VBA完成一切.

image元素中的一个属性称为"productguid",其字符串值为=

"a12-545".

在使用鼠标单击图像元素之前,表单的HTML代码如下所示.

<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
  <input type="hidden" name="ProductGuid" value="">
</form>
Run Code Online (Sandbox Code Playgroud)

这是我用鼠标手动点击后的HTML代码:

<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
  <input type="hidden" name="ProductGuid" value="a12-545">
</form>
Run Code Online (Sandbox Code Playgroud)

基于此,我假设image元素的productguid值在提交之前传递给表单.这是我的VBA代码如下所示:

'Change the input element value
ie.Document.getElementById("GetProductQuantitiesForAccessibleBranches").all.item(0).value = "a12-545"

'Submit the form
ie.Document.getElementyId("GetProductQuantitiesForAccessibleBranches").Submit
Run Code Online (Sandbox Code Playgroud)

根据Locals窗口,所有Javascript事件都是Null.这两行代码都运行没有任何错误,但网页不会更新.我在这里错过了什么吗?

我也试过用.Click方法单击图像元素,但这也没有做任何事情.

该网页受密码保护,因此我无法公开发布该网址.

更新:

这是标记中的HTML,通常手动单击,然后提交表单.也许这里有什么我可以使用的东西?

<img alt="View Quantities At Other Locations" src="/WebOrder/Images/CheckQtys.gif" 
title="View Quantities At Other Locations" class="popup" 
popupdirection="upperleft" popupwidth="380" 
popupcontent="#ProductQuantitiesForAccessibleBranches" 
onbeforepopupcreate="onBeforePopupCreate_GetProductQuantitiesForAccessibleBranches(this)" 
popupajaxformid="GetProductQuantitiesForAccessibleBranches" 
onbeforepopupajaxpost="onBeforePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)" 
oncompletepopupajaxpost="onCompletePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)" 
productguid="a12-545" 
displayitem="33902" 
brandguid="00000000-0000-0000-0000-000000000000" 
brandname="" brandsku="">
Run Code Online (Sandbox Code Playgroud)

html javascript vba dom browser-automation

5
推荐指数
1
解决办法
697
查看次数

--skip-js-关于特定测试用例的错误

我正在测试功能,包括重定向到我无法控制的外部页面。此页面抛出错误,导致测试失败。

有没有一种方法可以只针对一个特定测试忽略js错误?(我希望网站上的错误导致测试失败)

javascript browser-automation testcafe

5
推荐指数
2
解决办法
289
查看次数

Playwright - 查找多个元素或类名称

我读过一些与此相关的不同的质量保证,但似乎没有一个有效。

我正在尝试使用名为 mat-radio-checked 的类来定位名为 mat-radio-button 的元素(Angular)。然后选择内部文本。

在 Chrome 中这很简单:

https://i.stack.imgur.com/Ev0iQ.png

https://i.stack.imgur.com/lVoG3.png

要找到 Playwright 中匹配的第一个元素,我可以执行以下操作:

      let test: any = await page.textContent(
      "mat-radio-button.mat-radio-checked"
    );

    console.log(test);
Run Code Online (Sandbox Code Playgroud)

但如果我尝试这个:

      let test: any = await page.$$(
      "mat-radio-button.mat-radio-checked"
    );

    console.log(test);
    console.log(test[0]);
    console.log(test[1]);
  });
Run Code Online (Sandbox Code Playgroud)

它不返回我可以选择其内部文本的元素数组。

我需要能够找到该类的所有元素,以便我可以使用 Expect 来确保返回的内部文本正确,例如:

    expect(test).toBe("Australian Citizen");
Run Code Online (Sandbox Code Playgroud)

javascript automation browser-automation typescript playwright

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

是否有watir :: ie.attach替代watir-webdriver,因为webdriver不支持attach

我有一个网站只能在支持Webkit的浏览器(谷歌浏览器,Safari)中呈现.我使用的是谷歌浏览器,因为我使用的是Windows 7.

我正在使用Watir-WebDriver进行自动化.

问题:当我单击浏览器窗口上的按钮时,将启动另一个窗口,并在新的浏览器窗口中呈现发布单击内容.我需要一种能够识别这个新浏览器窗口的方法,以便能够继续我的测试.我一直在各种论坛上阅读,但没有得到任何确定的答案/解决方案.

问:对于watir-webdriver,是否有替代watir :: ie.attach,因为Watir-Webdriver不支持附加

示例代码:

require "rubygems"

require "watir-webdriver"


require "selenium-webdriver"

b = Watir::Browser.new(:chrome)

website = "http://xyz.com"

#a new browser is launched and the website is opened

b.goto(website)

#this opens a new browser window

b.link(:xpath,"/html/body/div/ul/li/a").click

#there is a button called "MAP" on the new browser window

b.link(:id,"btn_MAP")

#this gives an error, unknown link
Run Code Online (Sandbox Code Playgroud)

google-chrome webdriver browser-automation watir watir-webdriver

4
推荐指数
2
解决办法
3856
查看次数

Selenium - 拒绝获取属性HTMLDocument.readyState的权限

我们正在使用Selenium(用于Firefox)进行一些自动化,并记录脚本进行回放.这一点工作正常,直到提供商宣布一些新的变化.现在我们得到以下错误,不确定这意味着什么......

    [info] Executing: |waitForPopUp | LookuphdnProductId1 | 40000 |
  -->[error] Permission denied for <https://books.zoho.com> to get property HTMLDocument.readyState
    [info] Executing: |selectWindow | name=LookuphdnProductId1 | <br/>
  -->[error] Unexpected Exception: fileName -> chrome://selenium-ide/content/selenium-core/scripts/selenium-browserbot.js, lineNumber -> 840
Run Code Online (Sandbox Code Playgroud)

任何有浏览器自动化或Selenium经验的人都会提出一些提示吗?

谢谢

selenium browser-automation selenium-ide

4
推荐指数
1
解决办法
3186
查看次数

如何在Java中为Selenium Webdriver编写自己的自定义定位器?

我想编写自己的定位器来访问元素。WebDriver的API当前提供八个定位器,允许按ID,名称属性,标记名称,完整或部分链接文本,XPath,类名称和CSS选择器检索元素。但是,这些默认定位器现在对我来说还不够,因为我必须通过新属性来访问元素。让我举个例子,这样您就可以在这里了解我的真正需求。

示例: 选择您的用户名:

现在,我想编写一个代码,以便可以使用myLocator定位器访问用户名按钮,如下所示:

*driver.findElement(By.myLocator("username")).*
Run Code Online (Sandbox Code Playgroud)

如果有人可以给我们一些好主意,那我将如何重写BY类以添加自己的定位器,这将非常有帮助。

预先感谢您的帮助。

java selenium webdriver browser-automation selenium-webdriver

4
推荐指数
2
解决办法
2万
查看次数

我可以使用Selenium-webdriver for Ruby自动执行Chrome请求阻止吗?

我是一名质量检查自动化分析师,负责测试多平台在线银行应用程序。对于我们的自动化测试,我们将RubyMine套件与Gherkin / Cucumber,Ruby脚本步骤以及Selenium-webdriver,Watir和页面对象gem /库一起使用。

我有很多脚本,如果没有人工干预就无法完全自动化,其中包括通过Telerik Fiddler阻止某些网络调用以生成警告页面或错误消息等。我们自动化的未来将是通过RubyMine而不是Fiddler来实现。用于网络阻止。我知道有一种方法可以在Chrome中使用Inspect Element和“网络”菜单中的启用请求阻止功能来执行此操作。但是,我无法找到一种方法来强制Chrome浏览器通过Ruby / Selenium阻止给定的请求。唯一的方法是自己手动执行操作,因此我实际上无法根据需要自动执行这些操作。

所以,我的问题-这是否有可能使用Selenium-webdriver自动执行请求阻止?而且,如果是这样,我应该从哪里开始寻求帮助?

谢谢。

ruby selenium network-programming google-chrome browser-automation

4
推荐指数
4
解决办法
3707
查看次数