Selenium Webdriver的替代品 [英] Alternatives to Selenium Webdriver

查看:773
本文介绍了Selenium Webdriver的替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Selenium Webdriver for C#和Python来从网站获取数据元素,但网络抓取的速度非常慢。刮掉35000个数据表花了我大约1.5天。使用Selenium Webdriver,我可以执行Javascript来获取Java元素。是否有一些库可用,不需要类似Webdriver的东西在网页上执行Javascript来检索元素,并且还可以点击元素?或者是否有更快的替代Selenium?

解决方案

我建议您使用



TestCafe是用于Web功能测试(e2e测试)的免费开源框架。 TestCafe基于Node.js并且根本不使用WebDriver。



在服务器端执行TestCafe驱动的测试。为了获得DOM元素,TestCafe提供了强大灵活的选择器系统。
TestCafe可以使用ClientFunction功能在测试的网页上执行JavaScript(请参阅我们的文档)。



TestCafe测试真的非常快,亲自看看。但是由于内置的​​智能等待系统,高速测试运行不会影响稳定性。



安装TestCafe非常简单:



1)检查您的PC上是否有Node.js(或安装它)。



2)安装TestCafe open cmd并输入in:

  npm install -g testcafe 

写作测试不是火箭科学。这是一个快速入门:
1)将以下代码复制粘贴到文本编辑器并将其保存为test.js

 从'testcafe'导入{Selector}; 

灯具`入门`
.page`http://devexpress.github.io / testcafe / example`;

test('我的第一次测试',async t => {
await t
.typeText('#developer-name','John Smith')
.click('#submit-button')
.expect(Selector('#article-header')。innerText).eql('谢谢你,John Smith!');
});

2)在cmd中键入以下命令,在浏览器中运行测试(例如chrome):

  testcafe chrome test.js 

3)在控制台输出中获取描述性结果。



TestCafe允许您针对各种浏览器进行测试:本地,远程(在设备上,无论如何)用于Raspberry Pi或Safari for iOS的浏览器),云(例如Sauce Labs)或无头(例如Nightmare)。这意味着您可以轻松地将TestCafe与您的Continious Integration基础结构一起使用。


I use the Selenium Webdriver for C# and for Python to obtain data elements from websites, but the speed of the web scraping is terribly slow. Scraping 35000 data tables took me about 1,5 day. With the Selenium Webdriver I can execute Javascript to get a Java element. Is there some library available which doesn't require something like a Webdriver to execute Javascript on a webpage to retrieve elements and is able to click on elements as well? Or is there a faster alternative to Selenium?

解决方案

I suggest you to use TestCafe.

TestCafe is free, open source framework for web functional testing (e2e testing). TestCafe's based on Node.js and doesn't use WebDriver at all.

TestCafe-powered tests are executed on the server side. To obtain DOM-elements, TestCafe provides powerfull flexible system of Selectors. TestCafe can execute JavaScript on tested webpage using the ClientFunction feature (see our Documentation).

TestCafe tests are really very fast, see for yourself. But the high speed test run does not affect the stability thanks to a build-in smart wait system.

Installation of TestCafe is very easy:

1) Check that you have Node.js on your PC (or install it).

2) To install TestCafe open cmd and type in:

npm install -g testcafe

Writing test is not a rocket-science. Here is a quick start: 1) Copy-paste the following code to your text editor and save it as "test.js"

import { Selector } from 'testcafe';

fixture `Getting Started`
    .page `http://devexpress.github.io/testcafe/example`;

test('My first test', async t => {
    await t
        .typeText('#developer-name', 'John Smith')
        .click('#submit-button')
        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});

2) Run test in your browser (e.g. chrome) by typing the following command in cmd:

testcafe chrome test.js

3) Get the descriptive result in the console output.

TestCafe allows you to test against various browsers: local, remote (on devices, be it browser for Raspberry Pi or Safari for iOS), cloud (e.g. Sauce Labs) or headless (e.g. Nightmare). This means that you can easily use TestCafe with your Continious Integration infrastructure.

这篇关于Selenium Webdriver的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆