标签: browser-automation

如何从 OS X 上的脚本远程控制 Firefox

我需要编写一些访问某些网站的脚本。来自命令行的脚本将获取一些页面、发布一些表单、屏幕抓取一些信息等。

它不能真正做到一库“浏览器”之类的libwww-perl的,因为某些步骤可能需要用户交互(CAPTCHA系统阿贾克斯-only形式,任何交互惊喜,等)。

我能想到的最实用的方法是在 Firefox 中远程打开一个选项卡,并将 JavaScript 代码注入其中,有点像GreasemonkeySelenium所做的。它不一定要用于 Firefox,如果更容易,可以是不同的浏览器。

那么最好的方法是什么?

firefox browser-automation

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

浏览器忙于执行一些长时间运行的JavaScript时,WebDriver API阻塞行为

我在文档中的某处读到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

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

Excel VBA SendKeys不会导致IE 9保存下载

我正在编写一个宏来从我公司的内部网站下载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)

excel automation vba browser-automation office-automation

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

使用 Selenium 实现浏览器自动化:指纹、可识别性和可追溯性?

我想使用 selenium/webdriver 来模拟浏览器并用它抓取一些网站内容。即使它不是最快的方法,对我来说它也有很多优点,例如执行脚本等。

对于许多网站,禁止通过自动方法访问它们,例如 google 或 bing 等搜索引擎。

对于一种工具,我需要从 google 抓取几个关键字的估计结果统计数据。这将如下所示:模拟浏览器访问 google.com 并输入关键字并抓取结果,然后稍作停顿后输入下一个关键字,抓取结果等等......

我的问题是:网站是否有可能识别出我正在使用 selenium 来模拟浏览器而不是手动使用浏览器?尤其是google案例,让我有些疑惑。我知道 selenium 部分是由谷歌开发的,或者至少是由一些为谷歌工作的人开发的。那么是否会为 selenium 留下一些指纹,或者是否无法决定我是自己使用浏览器还是 selenium 模拟的浏览器,即使对于谷歌也是如此?

browser-automation web-scraping selenium-webdriver

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

How to get the HTTP response body using chromedp?

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:

https://github.com/knq/chromedp/blob/b9e4c14157325be092c1c1137edbd584648d8c72/cdp/cachestorage/types.go#L30

And that it should be accessible …

google-chrome http browser-automation go chromedp

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

如何使用 Selenium 自动化 Firefox Mobile?

我需要在 Firefox Mobile 中运行 Selenium 测试。有人可以描述一个简单的方法来做到这一点吗?我的调查表明:

  1. Appium不支持 Firefox Mobile ()。
  2. Firefox Desktop 内置了响应式设计模式,如图所示:响应式用户界面模式
  3. 看来,Geckodriver不支持Firefox移动。与Chromedriver相比,Geckodriver没有特定于移动设备的代码。
  4. 这里(或有)一些方法来打开使用Firefox的首选项移动模拟。它的工作原理是使用 Marionette API 调用将 Firefox 从 CONTENT 切换到 CHROME 上下文,然后使用 Selenium 按下键盘快捷键。

这些解决方案中的任何一个都没有成功。知道如何自动化 Firefox Mobile 吗?

firefox mobile selenium browser-automation

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

通过命令行或本地脚本与浏览器JavaScript交互?

我们提供类似于imagemagick的浏览器页面JavaScript,可帮助人们将图像转换为不同的大小和格式。但是,它需要网页交互。

是否可以让人们自动进行这种交互-无需将图像发送到我们的服务器(从而增加了带宽成本和服务器负载),并且不需要用户下载无头的浏览器库(如Puppeteer)?

例如,以下流程是否可能:

  1. 通过命令行(或本地脚本)打开Chrome到特定网页。
  2. 将图像上传到该网页。
  3. 在网页上调用脚本。
  4. 接收脚本结果并允许本地操作。

可以启动Chrome,但尚不清楚启动后是否可以与特定的浏览器窗口进行交互。

javascript firefox google-chrome offline-mode browser-automation

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

如何在单个浏览器实例上运行所有测试脚本

我正在使用带有 Java Script 的 Testcafe(免费版)。我想__test__在每个浏览器类型的单个浏览器实例(即 1 次登录)中运行我的所有测试用例(驻留在目录中的多个测试脚本中)。

  1. 例如,1 个 chrome 实例和 1 个 safari 实例,但所有测试都将在关闭浏览器之前运行。
  2. 如果测试失败,我希望截取屏幕截图并计算测试失败的次数。但确实想继续。
  3. 我在 Node 12 Docker 映像上做所有事情,所以最好不需要安装任何其他东西。

我如何用 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

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

如何处理浏览器或应用程序可能不是 Web 驱动程序 Selenium python 的安全问题?

我正在尝试自动登录 gmail,但我看到了这个错误。

在此处输入图片说明

我认为这一定是因为该网站能够检测到自动化并阻止它。大家能告诉我如何克服这个吗?我的个人帐户没有看到这个问题,但这只会发生在普通帐户中。

python selenium webdriver browser-automation

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

为什么在 cypress.io 中拖放不能按预期工作?

我正在尝试在网站上自动化一个简单的拖放场景。

https://gojs.net/latest/samples/htmldragdrop.html

I am going as per the method provided in cypress doc

https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__drag-drop/cypress/integration/drag_n_drop_spec.js

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 …

javascript automated-tests browser-automation cypress

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