Java Wordpress登录自动化

Java Wordpress登录自动化,java,wordpress,selenium,Java,Wordpress,Selenium,我正在尝试在上自动登录过程 第一步:点击右上角的“登录”按钮 第二步:点击登录页面上的“继续谷歌” 但我只能执行步骤1。当我自动点击“继续谷歌”时,它就是不点击 发生的情况是光标在“电子邮件地址或用户名”字段上不断闪烁。它只是不点击其他任何东西。如果我尝试自动化,也是一样的。这是什么问题吗?请帮忙 import org.openqa.selenium.By; 导入org.openqa.selenium.WebElement; 导入org.openqa.selenium.WebDriver;

我正在尝试在上自动登录过程

  • 第一步:点击右上角的“登录”按钮
  • 第二步:点击登录页面上的“继续谷歌”
但我只能执行步骤1。当我自动点击“继续谷歌”时,它就是不点击

发生的情况是光标在“电子邮件地址或用户名”字段上不断闪烁。它只是不点击其他任何东西。如果我尝试自动化,也是一样的。这是什么问题吗?请帮忙

import org.openqa.selenium.By;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.firefox.FirefoxDriver;
导入org.openqa.selenium.chrome.ChromeDriver;
公共类TestAddNewPost{
字符串baseUrl=”https://wordpress.com/";
public void LoginIntoWordpress(){
//System.setProperty(“webdriver.chrome.driver”,“/home/ashwin/Desktop/chromedriver”);
setProperty(“webdriver.gecko.driver”,“/home/ashwin/Desktop/geckodriver”);
//WebDriver驱动程序=新的ChromeDriver();
WebDriver=newfirefoxdriver();
get(baseUrl);
WebElement LoginButton=driver.findElement(By.xpath(“//a[@class='x-nav-link x-link']][contains(text(),'Log-In')]”);
LoginButton.click();
WebElement continueWithGoogle=driver.findElement(By.xpath(“//span[contains(text(),'Continue with Google')]”);
试一试{
《睡眠》(2000年);
}捕获(中断异常例外){
例如printStackTrace();
}
继续使用Google.click();
}
公共静态void main(字符串[]args){
TestAddNewPost对象=newTestAddNewPost();
object.LoginIntoWordpress();
}
}

您只需在单击“继续谷歌”按钮之前提供更多的等待时间

 driver.get("https://www.wordpress.com");   
 WebElement LoginButton = driver.findElement(By.xpath("//a[@class='x-nav-link 
                                xlink'[contains(text(),'LogIn')]"));
 LoginButton.click();
 driver = new ChromeDriver();
    driver.navigate().to("https://www.wordpress.com");
    WebElement LoginButton = driver
            .findElement(By.xpath("//a[@class='x-nav-link x-link'][contains(text(),'Log In')]"));
    LoginButton.click();
   Thread.sleep(5000);
    WebElement continueWithGoogle = 
      driver.findElement(By.xpath("//span[contains(text(),'Continue with Google')]"));
              
    try {
        Thread.sleep(5000); 
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
    continueWithGoogle.click();
}

Hope the above code solves you issue