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,220 points
673 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,130 points

Related Questions In Selenium

0 votes
1 answer

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

Yes, its very much possible. You just ...READ MORE

answered May 8, 2018 in Selenium by king_kenny
• 3,650 points
6,939 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 in Selenium by Abha
• 27,180 points
528 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 in Selenium by Abha
• 27,180 points
124 views
0 votes
1 answer

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,110 points
965 views
0 votes
1 answer
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,130 points
1,127 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
869 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,130 points
2,368 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,130 points
346 views