通过硒打开chrome时,除了webdriver之外还有哪些其他标识符?

时间:2019-06-06 07:35:45

标签: selenium google-chrome selenium-webdriver selenium-chromedriver

我正在做一个自动化测试(navigator.webdriver属性已被代码删除)。当我通过硒打开铬访问网站并验证(滑块)时,它永远不会通过,但是如果我打开一个新标签,则这次可以通过。 chrome是否添加了其他任何属性,例如navigator.webdriver?

编辑:   我的测试代码:

  @Test
  def d3(): Unit = {
    val options = new ChromeOptions()

    options.setExperimentalOption("useAutomationExtension", false)

    options.addArguments("--incognito")

    options.setExperimentalOption("excludeSwitches", Array("enable-automation"))

    val driver = new ChromeDriver(options)

    // random sleep for a while
    driver.get("test url")
    // manual slide verification, , but validation failed
    driver.close()
  }

测试链接是第三方网站,此处仅添加了脚本部件代码(原始页面相对较大)

            <script>
                var loadScript = function(src, callback) {
                    var script = document.createElement('script'),
                        head = document.getElementsByTagName('head')[0];
                    script.type = 'text/javascript';
                    script.charset = 'UTF-8';
                    script.src = src;
                    if (script.addEventListener) {
                        script.addEventListener('load',
                            function() {
                                callback();
                            },
                            false);
                    } else if (script.attachEvent) {
                        script.attachEvent('onreadystatechange',
                            function() {
                                var target = window.event.srcElement;
                                if (target.readyState == 'loaded') {
                                    callback();
                                }
                            });
                    }
                    head.appendChild(script);
                };
                var scene = "register";
                loadScript('//g.alicdn.com/sd/ncpc/nc.js', ncinitpc);
                function ncinitpc() {
                    UA_Opt.Flag = 880846;
                    document.getElementById("nocaptcha").style.cssText = "margin-top:-10px";
                    var nc =  noCaptcha({
                        renderTo: "#nocaptcha",
                        appkey: "X82Y__0f477b982962cd1294364cdf3ae370ec",
                        token: "471c94470da8407077ed425a5ab6258f",
                        scene: scene,
                        is_Opt: 1,
                        language:"en",
                        callback: function(data) {
                            document.getElementById("nc-session-id").value = data.csessionid;
                            document.getElementById("nc-sig").value = data.sig;
                            document.getElementById("nc-verify-form").submit();
                        }
                    });
                }
            </script>

现在,我已经解决了。我按照链接Can a website detect when you are using selenium with chromedriver? 的提示修改了(替换cdc_变量)chromeDriver文件。

0 个答案:

没有答案