Read a dynamic value using Selenium

0 votes

I was getting the element in a HTML i.e value "1841". I can find the element for the next element by:

e = b.find_element_by_xpath("//*[contains(text(), 'value_to_alert')]")

 How to get the element before this element... I don’t want to use the class name because there are a bunch of "KpiValue"s. Is there a way to do that?

Aug 2, 2018 in Selenium by Martin
• 4,320 points
5,362 views

1 answer to this question.

0 votes

You can use the following line of code:

text = b.find_element_by_xpath("//div[contains(.,'value_to_alert')]//preceding::div[1]").text

answered Aug 2, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

+1 vote
2 answers

Is it possible to manually set the attribute value of a Web Element using Selenium?

WebDriver driver; JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.getElementById('id123').setAttribute('attr', ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
26,658 views
0 votes
1 answer

Read PDF content on a browser using Selenium webdriver?

Hey Parvati, you can use Apache PDFBox JAR ...READ MORE

answered Jul 5, 2019 in Selenium by Abha
• 28,140 points
14,486 views
0 votes
1 answer

How can I read a CSV file in Selenium using Webdriver?

Hey Trisha, you can read a CSV ...READ MORE

answered Jul 17, 2019 in Selenium by Abha
• 28,140 points
12,462 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,615 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,571 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,629 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,517 views
0 votes
1 answer

Select a drop down value of angular js application using selenium using text

To select drop down use following, driver.findElements(By.className("Your dropdown ...READ MORE

answered Jun 18, 2018 in Selenium by Samarpit
• 5,910 points
10,426 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,910 points
2,341 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