findElement By xpath not working using Selenium WebDriver

0 votes

I'm was trying to find the following element by xpath:

<input class="t-TextBox" type="email" test-id="test-username"/>

Then I tried:

element = findElement(By.xpath("//[@test-id='test-username']"));

This is the error Expression is not a legal expression.

Apr 18, 2018 in Selenium by Martin
• 4,320 points
8,748 views

1 answer to this question.

0 votes
element = findElement(By.xpath("//*[@test-id='test-username']");

element = findElement(By.xpath("//input[@test-id='test-username']");

(*) - any tagname

answered Apr 18, 2018 by code_ninja
• 6,290 points

Related Questions In Selenium

0 votes
1 answer

Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

You can use the document.evaluate: Evaluates an XPath ...READ MORE

answered Nov 27, 2020 in Selenium by Gitika
• 65,910 points
3,602 views
+2 votes
4 answers

sendKeys() not working in Selenium Webdriver

this work for me you should update your ...READ MORE

answered Aug 27, 2019 in Selenium by Afif
29,391 views
0 votes
1 answer

Locating an element by value using css selector using Selenium WebDriver

Below code will help By.cssSelector("td[class='someclass'][value=' ...READ MORE

answered Apr 9, 2018 in Selenium by coldcode
• 2,080 points
1,671 views
0 votes
1 answer

Firefox browser not opening with given URL using Selenium Webdriver with Java

Download the latest selenium jar and replace ...READ MORE

answered Apr 30, 2018 in Selenium by Samarpit
• 5,910 points
7,282 views
0 votes
1 answer

Selenium WebDriver.get(url) not working

It is a Selenium defect. Problem is ...READ MORE

answered Jun 7, 2018 in Selenium by Meci Matt
• 9,460 points
8,819 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,578 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,559 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,606 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,506 views
0 votes
1 answer

Using headless browser for Armv7 linux processor

Install the lower version of selenium.It fixed ...READ MORE

answered Mar 27, 2018 in Selenium by code_ninja
• 6,290 points
711 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP