Selenium cant locate element by label
up vote
1
down vote
favorite
I am trying to locate the tool tip on my page demo.rezi.co
on left hand side that says landlords based on the attribute label.
I have drafted the code below.
When I run it, it says that:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@label='LANDLORDS']"}
This is my code so far:
// Test Landlord Tooltip
String expectedToolTip = "This is a test";
WebElement landlord = Driver.findElement(By.xpath("//a[@label='LANDLORDS']"));
System.out.println(landlord.getTagName());
selenium selenium-webdriver xpath mousehover webdriverwait
add a comment |
up vote
1
down vote
favorite
I am trying to locate the tool tip on my page demo.rezi.co
on left hand side that says landlords based on the attribute label.
I have drafted the code below.
When I run it, it says that:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@label='LANDLORDS']"}
This is my code so far:
// Test Landlord Tooltip
String expectedToolTip = "This is a test";
WebElement landlord = Driver.findElement(By.xpath("//a[@label='LANDLORDS']"));
System.out.println(landlord.getTagName());
selenium selenium-webdriver xpath mousehover webdriverwait
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to locate the tool tip on my page demo.rezi.co
on left hand side that says landlords based on the attribute label.
I have drafted the code below.
When I run it, it says that:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@label='LANDLORDS']"}
This is my code so far:
// Test Landlord Tooltip
String expectedToolTip = "This is a test";
WebElement landlord = Driver.findElement(By.xpath("//a[@label='LANDLORDS']"));
System.out.println(landlord.getTagName());
selenium selenium-webdriver xpath mousehover webdriverwait
I am trying to locate the tool tip on my page demo.rezi.co
on left hand side that says landlords based on the attribute label.
I have drafted the code below.
When I run it, it says that:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@label='LANDLORDS']"}
This is my code so far:
// Test Landlord Tooltip
String expectedToolTip = "This is a test";
WebElement landlord = Driver.findElement(By.xpath("//a[@label='LANDLORDS']"));
System.out.println(landlord.getTagName());
selenium selenium-webdriver xpath mousehover webdriverwait
selenium selenium-webdriver xpath mousehover webdriverwait
edited Nov 12 at 13:55
DebanjanB
37.1k73372
37.1k73372
asked Nov 8 at 21:51
Neeru
61
61
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Label is not an attribute of the link, it's a child. If you really want to select the a
by text LANDLORDS
you would have to use something like this:
"//label[contains(text(),'LANDLORDS')]/ancestor::a"
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
add a comment |
up vote
0
down vote
I am still not sure if I have understood the usecase properly. However on the webpage demo.rezi.co
you need to Mouse Hover over the element with text as LANDLORDS and then you can extract the Tool Tip and you can use the following solution:
Code Block:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class q53216692_MouseHover {
public static void main(String args) {
System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver Driver = new ChromeDriver(options);
Driver.get("https://demo.rezi.co/#!/tenant");
WebElement myElement = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[.='LANDLORDS']")));
new Actions(Driver).moveToElement(myElement).perform();
List<WebElement> tool_tip_items = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//label[.='LANDLORDS']//following::div[1]//div[@class='layout-column']/label[1]")));
for (WebElement tool_tip:tool_tip_items)
System.out.println(tool_tip.getText());
}
}
Console Output:
UPFRONT
ADVANTAGE
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Label is not an attribute of the link, it's a child. If you really want to select the a
by text LANDLORDS
you would have to use something like this:
"//label[contains(text(),'LANDLORDS')]/ancestor::a"
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
add a comment |
up vote
0
down vote
Label is not an attribute of the link, it's a child. If you really want to select the a
by text LANDLORDS
you would have to use something like this:
"//label[contains(text(),'LANDLORDS')]/ancestor::a"
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
add a comment |
up vote
0
down vote
up vote
0
down vote
Label is not an attribute of the link, it's a child. If you really want to select the a
by text LANDLORDS
you would have to use something like this:
"//label[contains(text(),'LANDLORDS')]/ancestor::a"
Label is not an attribute of the link, it's a child. If you really want to select the a
by text LANDLORDS
you would have to use something like this:
"//label[contains(text(),'LANDLORDS')]/ancestor::a"
answered Nov 9 at 2:19
Lucas Tierney
1,58788
1,58788
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
add a comment |
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
I am still getting the same error as before even after using the above code. The HTML can be viewed at - demo.rezi.co/#!/tenant. Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"label[contains(text(),'LANDLORDS')]/ancestor::a"} (Session info: chrome=70.0.3538.77)
– Neeru
Nov 9 at 16:50
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
There's a loader on the page, you need to wait until the element is present before trying to find it
– Lucas Tierney
Nov 9 at 18:43
add a comment |
up vote
0
down vote
I am still not sure if I have understood the usecase properly. However on the webpage demo.rezi.co
you need to Mouse Hover over the element with text as LANDLORDS and then you can extract the Tool Tip and you can use the following solution:
Code Block:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class q53216692_MouseHover {
public static void main(String args) {
System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver Driver = new ChromeDriver(options);
Driver.get("https://demo.rezi.co/#!/tenant");
WebElement myElement = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[.='LANDLORDS']")));
new Actions(Driver).moveToElement(myElement).perform();
List<WebElement> tool_tip_items = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//label[.='LANDLORDS']//following::div[1]//div[@class='layout-column']/label[1]")));
for (WebElement tool_tip:tool_tip_items)
System.out.println(tool_tip.getText());
}
}
Console Output:
UPFRONT
ADVANTAGE
add a comment |
up vote
0
down vote
I am still not sure if I have understood the usecase properly. However on the webpage demo.rezi.co
you need to Mouse Hover over the element with text as LANDLORDS and then you can extract the Tool Tip and you can use the following solution:
Code Block:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class q53216692_MouseHover {
public static void main(String args) {
System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver Driver = new ChromeDriver(options);
Driver.get("https://demo.rezi.co/#!/tenant");
WebElement myElement = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[.='LANDLORDS']")));
new Actions(Driver).moveToElement(myElement).perform();
List<WebElement> tool_tip_items = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//label[.='LANDLORDS']//following::div[1]//div[@class='layout-column']/label[1]")));
for (WebElement tool_tip:tool_tip_items)
System.out.println(tool_tip.getText());
}
}
Console Output:
UPFRONT
ADVANTAGE
add a comment |
up vote
0
down vote
up vote
0
down vote
I am still not sure if I have understood the usecase properly. However on the webpage demo.rezi.co
you need to Mouse Hover over the element with text as LANDLORDS and then you can extract the Tool Tip and you can use the following solution:
Code Block:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class q53216692_MouseHover {
public static void main(String args) {
System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver Driver = new ChromeDriver(options);
Driver.get("https://demo.rezi.co/#!/tenant");
WebElement myElement = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[.='LANDLORDS']")));
new Actions(Driver).moveToElement(myElement).perform();
List<WebElement> tool_tip_items = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//label[.='LANDLORDS']//following::div[1]//div[@class='layout-column']/label[1]")));
for (WebElement tool_tip:tool_tip_items)
System.out.println(tool_tip.getText());
}
}
Console Output:
UPFRONT
ADVANTAGE
I am still not sure if I have understood the usecase properly. However on the webpage demo.rezi.co
you need to Mouse Hover over the element with text as LANDLORDS and then you can extract the Tool Tip and you can use the following solution:
Code Block:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class q53216692_MouseHover {
public static void main(String args) {
System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver Driver = new ChromeDriver(options);
Driver.get("https://demo.rezi.co/#!/tenant");
WebElement myElement = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[.='LANDLORDS']")));
new Actions(Driver).moveToElement(myElement).perform();
List<WebElement> tool_tip_items = new WebDriverWait(Driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//label[.='LANDLORDS']//following::div[1]//div[@class='layout-column']/label[1]")));
for (WebElement tool_tip:tool_tip_items)
System.out.println(tool_tip.getText());
}
}
Console Output:
UPFRONT
ADVANTAGE
answered Nov 12 at 13:57
DebanjanB
37.1k73372
37.1k73372
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53216692%2fselenium-cant-locate-element-by-label%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown