无法点击paytm的登录按钮。它会突出显示但不会点击。以下是我的代码

时间:2017-07-14 11:40:48

标签: selenium xpath selenium-webdriver selenium-chromedriver

我无法点击paytm的登录按钮。它会突出显示但不会点击。

该代码在Firefox中完美运行。它无法点击Chrome浏览器中的链接。它没有显示任何错误或异常,它只是无法点击。

以下是我的代码:

driver.get("https://paytm.com/");
WebElement LoginLink= driver.findElement(By.xpath("//*[contains(text(),'Log In/Sign Up')]"));
Highlight.highLightElement(driver, LoginLink);
LoginLink.click();

3 个答案:

答案 0 :(得分:1)

public class LoginPage {

    public static void main(String[] args) throws InterruptedException {
        WebDriver driver = new ChromeDriver();
        String url="https://paytm.com/";
        driver.get(url);
        Thread.sleep(5000);
        WebElement Login=(WebElement) driver.findElement(By.className("_3ac-"));
        ((JavascriptExecutor) driver).executeScript("arguments[0].click();", Login);
    }

}

答案 1 :(得分:0)

以下是您的问题的答案:

您可以使用以下代码块点击Log In/Sign Uphttps://paytm.com/上的 Google Chrome 59.0 按钮:

  

注意:作为对您的问题的快速解决方案,我引发了Thread.sleep(5000);,应由ExplicitWait替换,WebDriverWait

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class Q45102095_PAYTM 
{

    public static void main(String[] args) throws InterruptedException 
    {

        System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("start-maximized");
        options.addArguments("disable-infobars");
        options.addArguments("--disable-extensions"); 
        WebDriver driver =  new ChromeDriver(options);
        driver.get("https://paytm.com/");
        driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        Thread.sleep(5000);
        WebElement login_button = driver.findElement(By.xpath("//div[@id='app']//div[normalize-space(text()) = 'Log In/Sign Up']"));
        login_button.click();
    }
}

如果这回答你的问题,请告诉我。

答案 2 :(得分:0)

driver.manage()窗口()最大化();

driver.get( “https://paytm.com/”);

的Thread.sleep(2000);

JavascriptExecutor je =(JavascriptExecutor)驱动程序;

WebElement Login_Btn = driver.findElement(By.xpath(“// * [contains(text(),'登录/注册')]”));

je.executeScript( “参数[0] .scrollIntoView(真);”,Login_Btn);

Login_Btn.click();

相关问题