F1nn-T
F1nn-T

Reputation: 67

Selenium Webdriver find element by Xpath problem with String quotation marks

Here my code:

var loginButton = driver.FindElement(By.XPath("//*[@id="login - view"]/form/div[3]/button"));

I saw already this post: Find texts that contains quotation marks by xpath in Selenium

but it doesn't help me

the quotation marks are The problem

Upvotes: 0

Views: 385

Answers (3)

Dazed
Dazed

Reputation: 1551

based on what you added here:

<button type="submit" aria-label="Login button" class="btn btn-large p-x-2 btn-inverse" disabled="">Log In</button>

This disabled attribute is causing issues because it makes the element, you guessed it, disabled! see - https://www.w3schools.com/tags/att_disabled.asp

If you remove that so it looks like this:

<button type="submit" aria-label="Login button" class="btn btn-large p-x-2 btn-inverse">Log In</button>

then you could use the below and it will work fine.

//button[text()='Log In']

Is there another login button that is not disabled?

Upvotes: 0

KunduK
KunduK

Reputation: 33384

Try this use single quote to put id value in a string.

var loginButton = driver.FindElement(By.XPath("//*[@id='login - view']/form/div[3]/button"));

Upvotes: 1

fgiuliani
fgiuliani

Reputation: 390

Is the id property value correct? It has some spaces before and after "-"

Upvotes: 0

Related Questions