我需要通过 html 表单上传数百个文件,以便它们最终在服务器上。我没有其他选择,必须通过表格。
我曾尝试使用 python 有问题地执行此操作,但是当我尝试通过 Web 界面打开它们时,我做错了并且文件为空。我还尝试通过 firefox 的 TamperData 进行重播,在这种情况下,文件也上传不正确。
所以我有兴趣探索通过自动化浏览器来上传文件的想法。我需要做的就是:
for file in files:
open a page
click on the browse button
select a file
click the upload button
Run Code Online (Sandbox Code Playgroud)
那么我可以使用什么软件/库来做到这一点?我不一定需要使用 python 来做这件事,因为我以后再也不需要这样做了。我只需要以任何可能的方式将文件放在那里。
我可以访问 Windows 7、Mac Os X 和 Suse Linux。
我也不在乎我使用哪个浏览器。
我正在尝试使用 Nightmarejs 制作简单的跟随脚本。它应该以下一种方式工作:
到目前为止我所拥有的是这个,它没有错误,但它只点击第一个关注按钮,那就是结束:
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://example.com/')
.click('.buttonOpenModal')
.wait(4000)
.click('.buttonFollow')
.end()
.then(function (result) {
console.log(result)
})
.catch(function (error) {
console.error('Search failed:', error);
});
Run Code Online (Sandbox Code Playgroud)
我试图循环点击这样的关注按钮,但它给了我错误$ 未定义
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://example.com/')
.click('.buttonOpenModal')
.wait(4000)
.evaluate(function(){
$('.buttonFollow').each(function() {
$(this).click();
});
})
.end()
.then(function (result) {
console.log(result)
})
.catch(function (error) {
console.error('Search …Run Code Online (Sandbox Code Playgroud) 如何在硒3中执行webdriver支持的硒?
Selenium 3最近取消了名为'webdriver backed selenium'的功能
我必须执行鼠标悬停,键入这样的操作,这在Selenium 3中不再受支持.
selenium = new WebDriverBackedSelenium(driver, "http://www.google.com");
selenium.openWindow("http://www.google.com", "google");
selenium.mouseOver(anElement);
Run Code Online (Sandbox Code Playgroud)
我已尝试使用moveToElement方法,但它不会在我的网站中执行.这就是我在Selenium 2(WebDriver)中使用webdriver支持的selenium的原因.
在Selenium 3中我需要做些什么来解决这个问题
selenium automation browser-automation selenium-rc selenium3
我很好奇开发人员可以做些什么来使用selenium web驱动程序更轻松地为测试人员创建自动化测试.我唯一想到的是使用字段,按钮等的唯一ID.任何人都可以想到可以做的其他事情吗?
automation automated-tests browser-automation selenium-webdriver
有没有办法测试使用selenium登录到具有开放ID的站点?
在selenium中,所有测试都存在于服务器中,因此一旦在网页的相应字段中填入开放的id url并进入第三方网页以输入凭据,我的测试将无法再运行.
有没有解决的办法?
在动态网页上,我不知道前面匹配元素的数量,所以我不知道要使用哪个索引#.
watir-webdriver是否提供了一种访问LAST匹配元素的方法,而不是默认情况下?
有问题的HTML形成日历控件
<table border="0" class="body-style">
<tbody>
<tr>
<td width="27" align="right"><b>Sun</b></td>
<td width="27" align="right"><b>Mon</b></td>
<td width="27" align="right"><b>Tue</b></td>
<td width="27" align="right"><b>Wed</b></td>
<td width="27" align="right"><b>Thu</b></td>
<td width="27" align="right"><b>Fri</b></td>
<td width="27" align="right"><b>Sat</b></td></tr>
<tr>
<td align="right"><p class="end-of-weekday-style">Â 1Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 2Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 3Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 4Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 5Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 6Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 7Â </p></td></tr>
<tr>
<td align="right"><p class="end-of-weekday-style">Â 8Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 9Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 10Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 11Â </p></td>
<td align="right"><p class="end-of-weekday-style">Â 12Â </p></td>
<td align="right"><a class="current-day-style selected-day-style" onmousemove="window.status=" "" onmouseout="window.status=" "" title="" href="javascript:dateSelected=13;closeCalendar();doOtherFunctions();">Â 13Â </a></td>
<td align="right"><p class="end-of-weekday-style">Â 14Â </p></td></tr> …Run Code Online (Sandbox Code Playgroud) 我无法与带有casperjs的jquery自动完成输入框进行交互.我尝试了很多不同的方法,但是当弹出选项列表时,我似乎无法选择自动完成选项.
我的代码如下:
casper.thenEvaluate(function() {
$('#myInput').val('cars'); // fill in the text box
$('#myInput').blur(); // should trigger the autocomplete ajax call
$('.ui-autocomplete li.ui-menu-item:nth-of-type(1)').click(); // should click the first item in the list
});
// take a picture to make sure it worked
casper.then(function() {
this.captureSelector('pics/test1.png', '#theForm');
});
Run Code Online (Sandbox Code Playgroud)
这根本不起作用,即使看起来应该如此.通过玩弄它,我发现触发向下箭头按键几次触发自动完成显示,所以这是一个更接近工作的版本.这适用于浏览器,但由于某种原因不适用于casper.thenEvaluate块.
$('#myInput').val('cars'); // fill in the text box
var e = jQuery.Event("keydown");
e.which = 40; // press down arrow a few times, not sure why this works
$("#myInput").trigger(e);
$("#myInput").trigger(e);
$('.ui-autocomplete li.ui-menu-item:nth-of-type(1)').click();
Run Code Online (Sandbox Code Playgroud) jquery browser-automation browser-testing jquery-autocomplete casperjs
我熟悉如何使用Google Chrome网络检查器手动将网页另存为包含内容的HAR文件.我想自动化这个.
在我搜索自动生成HAR文件的工具时,我找到了一些解决方案,但没有一个能够保存资源的内容.
我没试过就试过以下内容:
获取您请求的页面内容(原始HTML)是可行的,但获取加载的所有其他网络资源(CSS,javascript,图像等)的内容是我的问题所在.
javascript automation browser-automation google-chrome-devtools har
我正在为新的企业应用程序创建自动化框架。我正在使用Selenium(Webdriver),Java,Maven和TestNG。我已经读到我需要保持测试的规模小和自治,以便可以彼此独立地运行它们。
登录到应用程序是最耗时的过程。如果我必须登录并为每个测试重新开始,这会使我的测试套件运行一段时间。同样,如果我已经登录并导航到应用程序的特定部分,那么我不妨执行一些测试,而不是在一次测试后关闭浏览器并每次重新导航。
我应该坚持简短的自主测试,还是寻找其他构建测试的方法?
testing testng selenium browser-automation selenium-webdriver
我正在使用 nightwatch.js,我对这个自动化测试还很陌生,我想通过 nightwatch.js 将值设置到元素的 style 属性中,所以我问,这可能吗?如果可能的话我们如何实现它。
我可以访问样式属性值,并可以通过以下 nightwatch api 命令进行检查,但我找不到任何方法来使用 nightwatch.js 将样式值设置为元素
browser.expect.element('#main').to.have.css('display').which.equals('block');
Run Code Online (Sandbox Code Playgroud)