如何使用Selenium自动化进行Facebook注册页面?

huangapple go评论66阅读模式
英文:

How to automate facebook registration page using selenium?

问题

我尝试使用凭据在Selenium中自动化进行Facebook页面操作,这已经成功。(它可以自动登录Facebook。)
但是我无法在Facebook的注册页面上执行相同的操作。该页面弹出一个注册的弹窗(https://www.facebook.com/)。如果有人成功实现,请告诉我。
[注册页面1

英文:

I tried to Automate the Facebook page In selenium using credentials it works. (It automatically login into Facebook.)
But I am not able to do the same thing with the Registration page on Facebook. It has some kind of pop up page to register (https://www.facebook.com/), If someone is able to do it please let me know.
[registration page 1

答案1

得分: 1

这是Selenium自动化中的最差实践
由于多种原因,不建议使用WebDriver登录诸如Gmail和Facebook之类的网站。除了违反这些网站的使用条款(可能导致账户被关闭),它还很慢且不稳定。

理想的做法是使用电子邮件提供商提供的API,或者在Facebook的情况下,使用开发者工具服务,该服务公开了用于创建测试账户、好友等的API。虽然使用API可能需要额外的努力,但你将在速度、可靠性和稳定性方面获得回报。API也不太可能改变,而网页和HTML定位器经常发生变化,需要更新测试框架。

在测试的任何阶段使用WebDriver登录第三方网站会增加测试失败的风险,因为这会使测试变得更长。一个经验法则是,越长的测试越容易出错且不可靠。

符合W3C标准的WebDriver实现还会使用WebDriver属性对导航器对象进行注释,以便可以减轻拒绝服务攻击。

英文:

This is worst practice in selenium automation
For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. Aside from being against the usage terms for these sites (where you risk having the account shut down), it is slow and unreliable.

The ideal practice is to use the APIs that email providers offer, or in the case of Facebook the developer tools service which exposes an API for creating test accounts, friends, and so forth. Although using an API might seem like a bit of extra hard work, you will be paid back in speed, reliability, and stability. The API is also unlikely to change, whereas webpages and HTML locators change often and require you to update your test framework.

Logging in to third-party sites using WebDriver at any point of your test increases the risk of your test failing because it makes your test longer. A general rule of thumb is that longer tests are more fragile and unreliable.

WebDriver implementations that are W3C conformant also annotate the navigator object with a WebDriver property so that Denial of Service attacks can be mitigated.

huangapple
  • 本文由 发表于 2020年8月25日 13:58:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/63572853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定