Home > Enterprise >  How can I do the click the text ? I have only class in this in selenium java?
How can I do the click the text ? I have only class in this in selenium java?

Time:09-30

HTML

<div class="login pull-left ml-22" onclick="ShowLoginPopup();">Sign in</div>

Selenium-Java

Thread.sleep(2000);
driver.findElement(By.xpath("//div[text()='sign in']")).click();

How do I open this

CodePudding user response:

Your xpath is wrong.

You are using

//div[text()='sign in']

but it should be

//div[text()='Sign in']

Note that character in xpath are case sensitive.

The HTML is a part of Angular website, Please induce explicit waits

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[text()='Sign in']"))).click();
  • Related