标签: browser-automation

如何找出触发的JavaScript事件?

我有一个选择列表:

<select id="filter">
  <option value="Open" selected="selected">Open</option>
  <option value="Closed">Closed</option>
</select>
Run Code Online (Sandbox Code Playgroud)

当我选择Closed页面重新加载时.在这种情况下,它显示已关闭的票证(而不是打开).我手动操作时工作正常.

问题是当我ClosedWatir选择时页面不会重新加载:

browser.select_list(:id => "filter").select "Closed"
Run Code Online (Sandbox Code Playgroud)

这通常意味着不会触发某些JavaScript事件.我可以用Watir发射事件:

browser.select_list(:id => "filter").fire_event "onclick"
Run Code Online (Sandbox Code Playgroud)

但我需要知道要开火的事件.

有没有办法找出为元素定义了哪些事件?

javascript events browser-automation watir dom-events

115
推荐指数
3
解决办法
12万
查看次数

AttributeError:“WebDriver”对象没有属性“find_element_by_xpath”

from selenium import webdriver
import time

test = webdriver.Chrome()
test.get('https://docs.google.com/forms/d/e/1FAIpQLSeYUmAYYZNtbU8t8MRxwJo-        d1zkmSaEHodJXs78RzoG0yFY2w/viewform')

time.sleep(5)

Name = 'kuch bhi'
last = test.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/input')
last.send_keys(Name)
Run Code Online (Sandbox Code Playgroud)

当我执行代码时,我收到一条错误消息,

AttributeError:“WebDriver”对象没有属性“find_element_by_xpath”

selenium browser-automation python-3.x selenium-chromedriver selenium-webdriver

75
推荐指数
3
解决办法
18万
查看次数

为什么 Cypress 在运行 get 命令后说我的元素已分离?

目标: 我想使用 cypress 的辅助功能选择器单击页面上的特定元素

代码

cy.findAllByRole('rowheader').eq(2).click();
Run Code Online (Sandbox Code Playgroud)

错误

Timed out retrying: cy.click() failed because this element is detached from the DOM.

<th scope="row" data-automation-id="taskItem" aria-invalid="false" tabindex="-1" class="css-5xw9jq">...</th>

Cypress requires elements be attached in the DOM to interact with them.

The previous command that ran was:

  > cy.eq()

This DOM element likely became detached somewhere between the previous and current command.
Run Code Online (Sandbox Code Playgroud)

问题: 我可以在 DOM 中看到该元素仍然存在 - 没有逻辑将该元素与 DOM 分离,并且 eq 方法当然不会这样做。此外,findAllByRow 方法显然正在工作,因为它找到了我想要单击的正确元素。怎么会说五行分离呢?对于这种情况有解决方法吗?

javascript automation browser-automation cypress

54
推荐指数
6
解决办法
6万
查看次数

selenium webdriver如何将文件上传到浏览器?

我是一个javascript/java开发人员,我一直在试图弄清楚selenium webdriver自动化框架如何从文件系统上传文件.无法通过javascript设置文件输入,因为它是安全违规.然而,不知何故,webdriver能够使用以下命令执行此操作:

driver.setFileDetector(new LocalFileDetector());
WebElement upload = driver.findElement(By.id("myfile"));
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
driver.findElement(By.id("submit")).click();
Run Code Online (Sandbox Code Playgroud)

所以他们通过发送密钥来设置价值?我不明白.我查看了此处的源代码:http: //code.google.com/p/selenium/source/checkout 我仍然无法找到他们这样做的地方.

编辑:我的问题不是如何用selenium做这个,但是硒开发人员是如何做到这一点的呢?他们是如何解决javascript中的安全限制的?他们如何上传文件?

selenium automation webdriver browser-automation selenium-chromedriver

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

Selenium对Karma进行了哪些测试?

我知道Karma是一个JavaScript测试运行器,它可以在真正的浏览器中运行测试.如果是这种情况,Selenium会提供什么样的测试覆盖范围以及Karma.

javascript selenium browser-automation functional-testing karma-runner

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

如何使用python自动浏览?

假设,我需要在特定的网站上执行一组程序说,填写一些表格,点击提交按钮,将数据发送回服务器,接收响应,再根据响应做一些事情并将数据发送回服务器的网站.我知道python中有一个webbrowser模块,但我想在不调用任何Web浏览器的情况下执行此操作.它必须是一个纯粹的脚本.

python中是否有可用的模块,可以帮助我做到这一点?
谢谢

python browser-automation

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

Lynx用javascript

所以我在PHP中编写了一个脚本,需要javascript才能运行它.我很难找到如何使用php运行javascript同时使用一些linux工具使其自动化的解决方案(因为在我的浏览器中运行它不是一个选择,我需要它是一个crontab ).使用"php"命令也不是一个选择,因为它不运行javascript.所以我找到了解决方案,这是lynx.

所以这是我的问题:由于某种原因,javascript在我的浏览器中运行得很好,但不是在lynx中.使用lynx页面加载没有任何JavaScript参与.有没有办法在lynx中调试javascript,google chrome有哪些你可以在哪里查看控制台上发生了什么,所以我可以找出是什么导致脚本不能在lynx中运行?

编辑:

显然lynx不支持javascript.在那种情况下,我的问题是,是什么?我需要以浏览器的身份运行此脚本,但是需要从linux命令提示符下运行.如果操作系统在这种情况下很重要,我正在运行最新的Ubuntu.

linux browser-automation lynx

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

Selenium - IE 11中的NoSuchWindowException

我试图在IE11中使用selenium自动化网页.我已将保护模式设置设置为相同级别,缩放级别为100%.在运行测试时,它打开了网站但是刚刚发布了例外.以下是使用的代码.

   File file = new File("C:\\Users\\Desktop\\IEDriverServer.exe");
   System.setProperty("webdriver.ie.driver", file.getAbsolutePath() );       
   DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
   capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
   true); 
   WebDriver driver = new InternetExplorerDriver(capabilities);
   driver.get("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)

和异常堆栈跟踪

Started InternetExplorerDriver server (32-bit)
2.39.0.0
Listening on port 38122
Jul 11, 2014 1:50:02 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused        connection abort: recv failed
Jul 11, 2014 1:50:02 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Unable to find element on   closed window (WARNING: The server did not provide …
Run Code Online (Sandbox Code Playgroud)

java selenium internet-explorer browser-automation

22
推荐指数
3
解决办法
6万
查看次数

量角器/茉莉花测试抛出"UnknownError:未知错误:超出最大调用堆栈大小"

我有一个测试,每次运行它,抛出" UnknownError:未知错误:超出最大调用堆栈大小. "

此测试在我的一项服务中调用了一种写入Google云端硬盘的方法.

失败的测试是使用"ui"调用我的doDrive函数,这意味着更新Drive项.如果我更改单个字符"ui" - >"ni",意味着创建一个新的Drive项目,测试工作.被测代码在正常使用中工作正常.

it('should update a file', function() {
browser.executeAsyncScript(function(callback) {
    // get service
    var service=angular.element(document.getElementById('ngapp')).injector().get('DriveQ')
    // generate a title
    var title = 'title of file';
    // call doDrive to create a new file
    service.doDrive({t:'ui',id:'0B6B-RNrxsCu2Sll7JZTYy2aDA', item:{title:title}})
        .then(function (resp){
                    resp.originalTitle=title;
                    callback(resp)
            });
}).then(function(resp) {
    expect(resp.title).toEqual(resp.originalTitle);
});
});
Run Code Online (Sandbox Code Playgroud)

我直接使用chrome webdriver,我也有 browser.ignoreSynchronization = true;

browser-automation jasmine selenium-webdriver protractor chrome-web-driver

18
推荐指数
1
解决办法
4340
查看次数

如何通过复杂选择器设置输入字段的值?

我想设置某个无形输入字段的值.

my $field = $w->selector('tr.edit td[data-attribute="name"] input', single => 1);
Run Code Online (Sandbox Code Playgroud)

找到它.

$field->attributes->{value} = 'test';
Run Code Online (Sandbox Code Playgroud)

没有明显的效果.

$w->field($field => 'test');
Run Code Online (Sandbox Code Playgroud)

$w->field('tr.edit td[data-attribute="name"] input' => 'test');
Run Code Online (Sandbox Code Playgroud)

出错了No elements found for form number 1.

perl browser-automation

18
推荐指数
1
解决办法
294
查看次数