我需要编写一些访问某些网站的脚本。来自命令行的脚本将获取一些页面、发布一些表单、屏幕抓取一些信息等。
它不能真正做到一库“浏览器”之类的libwww-perl的,因为某些步骤可能需要用户交互(CAPTCHA系统,阿贾克斯-only形式,任何交互惊喜,等)。
我能想到的最实用的方法是在 Firefox 中远程打开一个选项卡,并将 JavaScript 代码注入其中,有点像Greasemonkey和Selenium所做的。它不一定要用于 Firefox,如果更容易,可以是不同的浏览器。
那么最好的方法是什么?
我在文档中的某处读到WebDriver API是非阻塞的(除了一些像driver.get之外).因此,执行WebElement click()或isDisplayed()通常应该是异步的(假设当然启用了本机事件).
我有一个简单的HTML页面执行长操作(基本上是一个长循环).当JS执行时,浏览器没有响应,这是预期的.但我也注意到,只要浏览器忙于执行脚本,WebDriver API就像click()/ isDisplayed()/ executeScript()一样.
由于WebDriver为点击而不是合成的JS事件发布本机事件,我很困惑为什么API阻止.虽然目前这种行为并没有困扰我,但我想知道在针对无响应的页面运行测试时是否可以依赖这种阻塞性质?我在测试中使用有条件的等待,但是想了解底层发生了什么,以及这是否特定于浏览器/操作系统?
我在Selenium 2.20.0中看到了这种行为,在Windows 7上安装了InternetExplorerDriver(IE9)和ChromeDriver(Chrome 19).
selenium automation webdriver browser-automation selenium-webdriver
我正在编写一个宏来从我公司的内部网站下载csv文件.
由于许多原因,我无法使用任何xmlhttp对象.宏将下载该文件.问题是Internet Explorer 9会提示用户使用"打开","保存"和"取消"按钮.
在IE中,Alt + Shift + S将保存下载,但我无法从Excel VBA中获取Sendkeys"%+ s"方法.
这是相关代码:
Function followLinkByText(thetext As String) As Boolean
'clicks the first link that has the specified text
Dim alink As Variant
'Loops through every anchor in HTML document until specified text is found
' then clicks the link
For Each alink In ie.document.Links
If alink.innerHTML = thetext Then
alink.Click
'waitForLoad
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "%+s", True
followLinkByText = True
Exit Function
End If
Next
End Function
Run Code Online (Sandbox Code Playgroud) 我想使用 selenium/webdriver 来模拟浏览器并用它抓取一些网站内容。即使它不是最快的方法,对我来说它也有很多优点,例如执行脚本等。
对于许多网站,禁止通过自动方法访问它们,例如 google 或 bing 等搜索引擎。
对于一种工具,我需要从 google 抓取几个关键字的估计结果统计数据。这将如下所示:模拟浏览器访问 google.com 并输入关键字并抓取结果,然后稍作停顿后输入下一个关键字,抓取结果等等......
我的问题是:网站是否有可能识别出我正在使用 selenium 来模拟浏览器而不是手动使用浏览器?尤其是google案例,让我有些疑惑。我知道 selenium 部分是由谷歌开发的,或者至少是由一些为谷歌工作的人开发的。那么是否会为 selenium 留下一些指纹,或者是否无法决定我是自己使用浏览器还是 selenium 模拟的浏览器,即使对于谷歌也是如此?
Using github.com/knq/chromedp, a go package to drive web browsers using Chrome Debugging Protocol, I can navigate to webpages, update forms and submit forms, but I need to retrieve a HTTP response body and haven't figured out how to yet. I'd like to be able to retrieve the HTTP response body for a JSON response (not HTML).
From looking in the code, it seems the HTTP response body is in the CachedResponse.Body property:
And that it should be accessible …
我需要在 Firefox Mobile 中运行 Selenium 测试。有人可以描述一个简单的方法来做到这一点吗?我的调查表明:

这些解决方案中的任何一个都没有成功。知道如何自动化 Firefox Mobile 吗?
我们提供类似于imagemagick的浏览器页面JavaScript,可帮助人们将图像转换为不同的大小和格式。但是,它需要网页交互。
是否可以让人们自动进行这种交互-无需将图像发送到我们的服务器(从而增加了带宽成本和服务器负载),并且不需要用户下载无头的浏览器库(如Puppeteer)?
例如,以下流程是否可能:
可以启动Chrome,但尚不清楚启动后是否可以与特定的浏览器窗口进行交互。
javascript firefox google-chrome offline-mode browser-automation
我正在使用带有 Java Script 的 Testcafe(免费版)。我想__test__在每个浏览器类型的单个浏览器实例(即 1 次登录)中运行我的所有测试用例(驻留在目录中的多个测试脚本中)。
我如何用 Testcafe 做到这一点?
const createTestCafe = require('testcafe')
let testcafe = null
let runner = null
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc
const runner = testcafe.createRunner()
return runner
.src([ '__test__/*.js' ])
.browsers([ 'chrome:headless --no-sandbox --disable-gpu', 'safari' ])
.screenshots('./reports/screenshots/', true)
.run({
selectorTimeout: 10000,
assertionTimeout: 10000,
})
})
runner
.screenshots({
path: 'reports/screenshots/',
takeOnFails: true,
})
.then(failedCount => …Run Code Online (Sandbox Code Playgroud) javascript testing automated-tests browser-automation testcafe
我正在尝试在网站上自动化一个简单的拖放场景。
https://gojs.net/latest/samples/htmldragdrop.html
I am going as per the method provided in cypress doc
my sample testcases is :
cy.visit("https://gojs.net/latest/samples/htmldragdrop.html")
cy.get('#paletteZone .draggable').first().trigger('mousedown', { which: 1 })
.trigger('mousemove', { clientX: 500, clientY: 500 })
.trigger('mouseup', { force: true })
Run Code Online (Sandbox Code Playgroud)
After running the same :
cypress focussing on trigger mousedown the element i want to drag but on the step of mousemove -- nothing is happening when i check the same using "before" and "after" state . have tried differnet drop location …
firefox ×3
javascript ×3
selenium ×3
automation ×2
webdriver ×2
chromedp ×1
cypress ×1
excel ×1
go ×1
http ×1
mobile ×1
offline-mode ×1
python ×1
testcafe ×1
testing ×1
vba ×1
web-scraping ×1