Unable to get the value in double quotes that is dynamically displayed using selenium xpath
up vote
1
down vote
favorite
I'm trying to get the value "19.5" which is dynamically displayed in below code using xpath in selenium. can anyone please help me with xpath to get the value 19.5, I'm new to selenium.
<li>
<label for="applyleave_leaveBalance">Leave Balance</label>
<div id="applyleave_leaveBalance" class>
"19.50"
<a href="#balance_details" data-toggle="modal" id="leaveBalance_details_link">view details</a>
</div>
</li>
java selenium xpath css-selectors webdriverwait
New contributor
add a comment |
up vote
1
down vote
favorite
I'm trying to get the value "19.5" which is dynamically displayed in below code using xpath in selenium. can anyone please help me with xpath to get the value 19.5, I'm new to selenium.
<li>
<label for="applyleave_leaveBalance">Leave Balance</label>
<div id="applyleave_leaveBalance" class>
"19.50"
<a href="#balance_details" data-toggle="modal" id="leaveBalance_details_link">view details</a>
</div>
</li>
java selenium xpath css-selectors webdriverwait
New contributor
1
Which Language Binding? Java/Python/C#?
– DebanjanB
2 days ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to get the value "19.5" which is dynamically displayed in below code using xpath in selenium. can anyone please help me with xpath to get the value 19.5, I'm new to selenium.
<li>
<label for="applyleave_leaveBalance">Leave Balance</label>
<div id="applyleave_leaveBalance" class>
"19.50"
<a href="#balance_details" data-toggle="modal" id="leaveBalance_details_link">view details</a>
</div>
</li>
java selenium xpath css-selectors webdriverwait
New contributor
I'm trying to get the value "19.5" which is dynamically displayed in below code using xpath in selenium. can anyone please help me with xpath to get the value 19.5, I'm new to selenium.
<li>
<label for="applyleave_leaveBalance">Leave Balance</label>
<div id="applyleave_leaveBalance" class>
"19.50"
<a href="#balance_details" data-toggle="modal" id="leaveBalance_details_link">view details</a>
</div>
</li>
<li>
<label for="applyleave_leaveBalance">Leave Balance</label>
<div id="applyleave_leaveBalance" class>
"19.50"
<a href="#balance_details" data-toggle="modal" id="leaveBalance_details_link">view details</a>
</div>
</li>
<li>
<label for="applyleave_leaveBalance">Leave Balance</label>
<div id="applyleave_leaveBalance" class>
"19.50"
<a href="#balance_details" data-toggle="modal" id="leaveBalance_details_link">view details</a>
</div>
</li>
java selenium xpath css-selectors webdriverwait
java selenium xpath css-selectors webdriverwait
New contributor
New contributor
edited yesterday
DebanjanB
35.3k73271
35.3k73271
New contributor
asked 2 days ago
Divya
82
82
New contributor
New contributor
1
Which Language Binding? Java/Python/C#?
– DebanjanB
2 days ago
add a comment |
1
Which Language Binding? Java/Python/C#?
– DebanjanB
2 days ago
1
1
Which Language Binding? Java/Python/C#?
– DebanjanB
2 days ago
Which Language Binding? Java/Python/C#?
– DebanjanB
2 days ago
add a comment |
3 Answers
3
active
oldest
votes
up vote
0
down vote
accepted
A bit more of the outerHTML would have made the solution a bit easier. However as per the HTML you have provided to extract the value 19.5 you need to induce WebDriverWait for the desired element to be visible and you can use either of the following solutions:
cssSelector
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table[aria-label='User']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
xpath
:
WebElement myElement = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(.,'Leave Balance')]//following::div[@id='applyleave_leaveBalance']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
1
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
add a comment |
up vote
0
down vote
please follow below steps
(1) take locator as
@FindBy(xpath="//div[@id='applyleave_leaveBalance']")
private WebElement balance;
public void printBalance()
{
System.out.println(balance.getText());
}
This will also extract the text of child link
– Andersson
2 days ago
Thank you so much.
– Divya
yesterday
add a comment |
up vote
0
down vote
Try to use this
xpath="//div[@id='applyleave_leaveBalance']/text()[1]"
It will return first text node.
Thank you, I got it now.
– Divya
yesterday
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
A bit more of the outerHTML would have made the solution a bit easier. However as per the HTML you have provided to extract the value 19.5 you need to induce WebDriverWait for the desired element to be visible and you can use either of the following solutions:
cssSelector
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table[aria-label='User']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
xpath
:
WebElement myElement = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(.,'Leave Balance')]//following::div[@id='applyleave_leaveBalance']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
1
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
add a comment |
up vote
0
down vote
accepted
A bit more of the outerHTML would have made the solution a bit easier. However as per the HTML you have provided to extract the value 19.5 you need to induce WebDriverWait for the desired element to be visible and you can use either of the following solutions:
cssSelector
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table[aria-label='User']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
xpath
:
WebElement myElement = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(.,'Leave Balance')]//following::div[@id='applyleave_leaveBalance']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
1
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
A bit more of the outerHTML would have made the solution a bit easier. However as per the HTML you have provided to extract the value 19.5 you need to induce WebDriverWait for the desired element to be visible and you can use either of the following solutions:
cssSelector
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table[aria-label='User']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
xpath
:
WebElement myElement = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(.,'Leave Balance')]//following::div[@id='applyleave_leaveBalance']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
A bit more of the outerHTML would have made the solution a bit easier. However as per the HTML you have provided to extract the value 19.5 you need to induce WebDriverWait for the desired element to be visible and you can use either of the following solutions:
cssSelector
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table[aria-label='User']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
xpath
:
WebElement myElement = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(.,'Leave Balance')]//following::div[@id='applyleave_leaveBalance']")));
String myText = ((JavascriptExecutor)driver).executeScript('return arguments[0].firstChild.textContent;', myElement).toString();
answered yesterday
DebanjanB
35.3k73271
35.3k73271
1
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
add a comment |
1
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
1
1
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
Thank you, it worked. I 'm able to extract the value now.
– Divya
yesterday
add a comment |
up vote
0
down vote
please follow below steps
(1) take locator as
@FindBy(xpath="//div[@id='applyleave_leaveBalance']")
private WebElement balance;
public void printBalance()
{
System.out.println(balance.getText());
}
This will also extract the text of child link
– Andersson
2 days ago
Thank you so much.
– Divya
yesterday
add a comment |
up vote
0
down vote
please follow below steps
(1) take locator as
@FindBy(xpath="//div[@id='applyleave_leaveBalance']")
private WebElement balance;
public void printBalance()
{
System.out.println(balance.getText());
}
This will also extract the text of child link
– Andersson
2 days ago
Thank you so much.
– Divya
yesterday
add a comment |
up vote
0
down vote
up vote
0
down vote
please follow below steps
(1) take locator as
@FindBy(xpath="//div[@id='applyleave_leaveBalance']")
private WebElement balance;
public void printBalance()
{
System.out.println(balance.getText());
}
please follow below steps
(1) take locator as
@FindBy(xpath="//div[@id='applyleave_leaveBalance']")
private WebElement balance;
public void printBalance()
{
System.out.println(balance.getText());
}
answered 2 days ago
Harshit
41
41
This will also extract the text of child link
– Andersson
2 days ago
Thank you so much.
– Divya
yesterday
add a comment |
This will also extract the text of child link
– Andersson
2 days ago
Thank you so much.
– Divya
yesterday
This will also extract the text of child link
– Andersson
2 days ago
This will also extract the text of child link
– Andersson
2 days ago
Thank you so much.
– Divya
yesterday
Thank you so much.
– Divya
yesterday
add a comment |
up vote
0
down vote
Try to use this
xpath="//div[@id='applyleave_leaveBalance']/text()[1]"
It will return first text node.
Thank you, I got it now.
– Divya
yesterday
add a comment |
up vote
0
down vote
Try to use this
xpath="//div[@id='applyleave_leaveBalance']/text()[1]"
It will return first text node.
Thank you, I got it now.
– Divya
yesterday
add a comment |
up vote
0
down vote
up vote
0
down vote
Try to use this
xpath="//div[@id='applyleave_leaveBalance']/text()[1]"
It will return first text node.
Try to use this
xpath="//div[@id='applyleave_leaveBalance']/text()[1]"
It will return first text node.
answered yesterday
psmagin
130119
130119
Thank you, I got it now.
– Divya
yesterday
add a comment |
Thank you, I got it now.
– Divya
yesterday
Thank you, I got it now.
– Divya
yesterday
Thank you, I got it now.
– Divya
yesterday
add a comment |
Divya is a new contributor. Be nice, and check out our Code of Conduct.
Divya is a new contributor. Be nice, and check out our Code of Conduct.
Divya is a new contributor. Be nice, and check out our Code of Conduct.
Divya is a new contributor. Be nice, and check out our Code of Conduct.
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%2f53363297%2funable-to-get-the-value-in-double-quotes-that-is-dynamically-displayed-using-sel%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
1
Which Language Binding? Java/Python/C#?
– DebanjanB
2 days ago