I have got a problem with Selenium code to find a button which has only "Value"
and "type"
, in inspection it looks like this:
<input type="sumbit" value="login" />
I tried twice but neither line worked for me.
The lines:
1st solution:
driver.FindElement(By.XPath("//button[contains(text(),'Login')]")).Click();
2nd solution:
driver.FindElement(By.ClassName("submit")).Click();
Image with ERROR MESSAGE (second line error)
Can anybody help me, or at least point out what am I missing, because its getting pretty frustrating to find a solution for such common thing, I practiced this on tutorial pages and buttons were never a problem.
Please. (Sorry for my English)
Ps: I checked the "similar questions and I haven't found the solution.
Pss: Guys, there is another one which I didnt try yet but I have 3 different lines of code, do you think one of them will work:
There is drop-down list and I want to select the last thing in the list...
driver.FindElement(By.XPath("//*[contains(., 'Process Data >>')]"));
driver.FindElement(By.Id("pdatasub")).Click();
driver.FindElement(By.XPath("//div[text()='Process Data >>']")).Click();
Inspection of the Drop-down list
Code for the opening of the last "button" in the drop-down list:
driver.FindElement(By.XPath("//div[text()='Final Values']")).Click();
Thanks guys for help !
Your locator is wrong.
You can use this:
driver.FindElement(By.XPath("//button[@type='submit']")).Click();
or
driver.FindElement(By.XPath("//button[@value='login']")).Click();
or
driver.FindElement(By.XPath("//button[@value='login' and @type='submit']")).Click();
CSS Selector can be used as well similarly.
Also there are several possible issues:
You are using the wrong locator :
try this instead :
driver.FindElement(By.XPath("//input[@type='submit' and @value='Login']")).Click();
or
With ExplicitWaits
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@type='submit' and @value='Login']"))).Click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.