Is there a way to use Selenium WebDriver without informing the document that it is controlled by WebDriver?

怎甘沉沦 提交于 2019-11-27 08:23:16

问题


I'm automating an Web page who call a CAPTCHA to validate the login, but I noticed that this page only request this CAPTCHA when I'm using my automatized test code, when I do it manually it don't request. I asked to developer team to disable it on the QA environment, but it's not possible by a security code.

I need to know if there is a way to don't say to browser that I'm using automated test on this page.

Can you help me, please?


回答1:


No, there is no way to conceal that you are runing automated test.

WebDriver Interface

When using the WebDriver interface the webdriver-active flag is set to true as the user agent is under remote control. It is initially false.

WebIDL

Navigator includes NavigatorAutomationInformation;

Note that the NavigatorAutomationInformation interface should not be exposed on WorkerNavigator.

WebIDL

interface mixin NavigatorAutomationInformation {
    readonly attribute boolean webdriver;
};

webdriver

  • Returns true if webdriver-active flag is set, false otherwise.

Example

  • For web authors (non-normative):

    • navigator.webdriver

      Defines a standard way for co-operating user agents to inform the document that it is controlled by WebDriver, for example so that alternate code paths can be triggered during automation.

The above mentioned implementation is based on a couple of Security Considerations as follows:

  • A user agent can rely on a command-line flag or a configuration option to test whether to enable WebDriver, or alternatively make the user agent initiate or confirm the connection through a privileged content document or control widget, in case the user agent does not directly implement the HTTP endpoints.

  • It is strongly suggested that user agents require users to take explicit action to enable WebDriver, and that WebDriver remains disabled in publicly consumed versions of the user agent.

  • It is also suggested that user agents make an effort to visually distinguish a user agent session that is under control of WebDriver from those used for normal browsing sessions. This can be done through a browser chrome element such as a door hanger, colorful decoration of the OS window, or some widget element that is prevalent in the window so that it easy to identify automation windows.



来源:https://stackoverflow.com/questions/52862023/is-there-a-way-to-use-selenium-webdriver-without-informing-the-document-that-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!