1

I try this xpath but I don't know how to continue ? i have 2 objects in popup menu and i want to select the first one

the html of the page is:

</div>
<input class="sprite form-enter" type="submit" value="" name="wobi">
</div>
<div class="container">
<img src="/_media/home/img/icons/pension.png">
<div class="login-text-container">
<a class="sprite form-enter" href="https://pension.wobi.co.il/login" value="" name="pension" type="submit"></a>
</div>
</div>

the java code is:

driver.findElement(By.xpath("//input[@class='sprite form-enter' and input//@name='wobi']")).click();
Thread.sleep(2000);

After execution of code I got the following exception:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@class='sprite form-enter' and input/@name='wobi']"}

What's wrong in my code?

2
  • Do you mean you have two element with the same class sprite form-enter and name wobi?? Commented Aug 23, 2016 at 13:20
  • your XPath is wrong better try and check if it works in Firebug / Firepath Commented Aug 23, 2016 at 13:24

3 Answers 3

1

Actually you are try with wrong xpath, the correct xpath would be :-

//input[@class='sprite form-enter' and @name='wobi']

But I would suggest you, try using By.cssSelector() here because it would be much faster than xpath as below :-

driver.findElement(By.cssSelector("input.sprite.form-enter[name = 'wobi']")).click();
Sign up to request clarification or add additional context in comments.

Comments

0

Try this selector:

//input[@class='sprite form-enter'][@name='wobi']

Comments

0

Seems like you have a compound class, try using CSSSelector

driver.findElement(By.cssSelector(".sprite.form-enter")).click();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.