Selenium extract data after strong

0 votes

I'm trying to extract the phone data after a </strong> in this web page code:

<strong class="styles__SCSectionTitleTitle-sc-v0nzb6-5 hCjKsp">Teléfonos</strong>669794282

Using the XPath 

OBJ.FindElementByXPath("//*[@id='main']/div[1]/div[2]/div[2]/div/div/div/div/div/section/div/div[1]/div[2]/ul/div/div[3]/li/div/div//strong").Text, 

I only get the word "Teléfonos".

Any help, please?

code_image

Mar 27, 2023 in Others by narikkadan
• 63,420 points
276 views

1 answer to this question.

0 votes

Try this:

phone_element = OBJ.find_element_by_xpath("//*[@id='main']/div[1]/div[2]/div[2]/div/div/div/div/div/section/div/div[1]/div[2]/ul/div/div[3]/li/div/div/strong/following-sibling::text()")
phone_number = phone_element.strip()

Using the modified XPath expression and then using the strip() method to remove any leading or trailing whitespace from the extracted phone number.

answered Mar 28, 2023 by Kithuzzz
• 38,010 points

Related Questions In Others

0 votes
1 answer
0 votes
0 answers

Data Driven Framework -- how to read and write in excel sheet using Selenium WebDriver with java

I'm using this code to read something, ...READ MORE

Oct 31, 2022 in Others by Kithuzzz
• 38,010 points
467 views
0 votes
1 answer

How to extract Bills receivable data to excel from tally by ODBC?

To obtain the company's receivable bills, you ...READ MORE

answered Nov 12, 2022 in Others by narikkadan
• 63,420 points
792 views
0 votes
1 answer

How to remove data within a multi-line cell that comes after a few line breaks

find() return the starting position of a ...READ MORE

answered Jan 26, 2023 in Others by narikkadan
• 63,420 points
510 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,619 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,572 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,519 views
0 votes
1 answer

Another method to extract the last row containing data in a column

The "used range" might not be accurate. ...READ MORE

answered Mar 28, 2023 in Others by Kithuzzz
• 38,010 points
305 views
0 votes
1 answer

Ordering data in python or excel

Basically, the data is converted from wide ...READ MORE

answered Feb 11, 2023 in Others by Kithuzzz
• 38,010 points
181 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