硒谷歌登录块 [英] Selenium Google Login Block

查看:95
本文介绍了硒谷歌登录块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Google登录有疑问.我想登录到我的帐户,但是Google表示不允许自动化驱动程序登录.

I have a problem with Google login. I want to login to my account but Google says that automation drivers are not allowed to log in.

我正在寻找解决方案.是否可以获取普通Firefox/Chrome的Cookie并将其加载到ChromeDriver/GeckoDriver中?我认为这可以解决.但是我不确定是否可能.

I am looking for a solution. Is it possible to get a cookie of normal Firefox/Chrome and load it into the ChromeDriver/GeckoDriver? I thought that this can be a solution. But I am not sure is it possible or not..

寻找解决方案.

此外,我想为此添加一个快速解决方案.我通过以下方式解决了这个问题 使用我的一个经过验证的旧帐户之一.那可能是一个快速的解决方案 你也是.

Also, I want to add a quick solution for this. I solved this issue by using one of my old verified account. That can be a quick solution for you also.

推荐答案

此错误消息...

...表示 WebDriver 实例无法认证浏览上下文,即 Browser 会话.

...implies that the WebDriver instance was unable to authenticate the Browsing Context i.e. Browser session.

此错误可能是由于以下各种因素引起的:

This error can happen due to different factors as follows:

  • In the article "This browser or app may not be secure" error when trying to sign in with Google on desktop apps @Raphael Schaad mentioned that, if an user can log into the same app just fine with other Google accounts, then the problem must be with the particular account. In majority of the cases the possible reason is, this particular user account is configured with Two Factor Authentification.

在文章缺少安全的应用程序&您的Google帐户,如果某个应用或网站不符合

  • Disable Two Factor Authentification for this Google account and execute your @Test.
  • Allow less secure apps

您可以在


深潜

但是,为了帮助保护您的帐户,网络浏览器可能不允许您从某些浏览器登录. Google可能会停止从以下浏览器登录:


Deep Dive

However, to help protect your account, Web Browsers may not let you sign in from some browsers. Google might stop sign-ins from browsers that:

  • 不支持JavaScript或关闭了Javascript.
  • 已添加AutomationExtension或不安全或不受支持的扩展.
  • 使用自动化测试框架.
  • 嵌入到其他应用程序中.

在这些情况下,有多种解决方案:

In these cases there are diverse solutions:

  • 使用支持 JavaScript 的浏览器:

Chrome

Safari

Firefox

Opera

Internet Explorer

Edge

Web浏览器中打开JavaScript:如果您使用的是受支持的浏览器,但仍然无法登录,则可能需要打开JavaScript.

Turn on JavaScript in Web Browsers: If you’re using a supported browser and still can’t sign in, you might need to turn on JavaScript.

如果仍然无法登录,可能是因为您打开了 AutomationExtension /不安全/不受支持的扩展并且您可能需要按以下步骤关闭:

If you still can’t sign in, it might be because you have AutomationExtension / unsecure / unsupported extensions turned on and you may need to turn off as follows:

  public class browserAppDemo 
  {
      public static void main(String[] args) throws Exception 
      {
          System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
          ChromeOptions options = new ChromeOptions();
          options.addArguments("start-maximized");
          options.setExperimentalOption("useAutomationExtension", false);
          options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
          WebDriver driver =  new ChromeDriver(options); 
          driver.get("https://accounts.google.com/signin")
          new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='identifierId']"))).sendKeys("gashu");
          driver.findElement(By.id("identifierNext")).click();
          new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='password']"))).sendKeys("gashu");
          driver.findElement(By.id("passwordNext")).click();
          System.out.println(driver.getTitle());
      }
  }

  • 您可以在以下位置找到一些相关的讨论:

  • You can find a couple of relevant discussions in:

    在Java中使用Selenium Webdriver登录Gmail

    最后,某些旧版本的浏览器可能不受支持,因此请确保:

    Finally, some old browser versions might not be supported, so ensure that:

    • JDK is upgraded to current levels JDK 8u241.
    • Selenium is upgraded to current levels Version 3.141.59.
    • ChromeDriver is updated to current ChromeDriver v80.0 level.
    • Chrome is updated to current Chrome Version 80.0 level. (as per ChromeDriver v80.0 release notes)

    这篇关于硒谷歌登录块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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