1

Hi I would like to scrap what is selected in the following image:

Image Code

I know i could use the following code to get the text:

cell = driver.find_elements_by_xpath(".//*[@id='ip_selection1233880116name']") 
print cell.text

But my problem is that ip_selection1233880116name should be dynamic, given that it changes every time as you can see from the image.

How could I do it?

Thanks a lot for your help!!!!

0

1 Answer 1

1

Use contains to catch just the name presuming the numbers all all that change, for a single element you should also use find_element as opposed to find_elements :

find_element_by_xpath("//*[contains(@id,'ip_selection') and contains(@id,'name')]") 

You could also use starts-with and ends-with depending on the browser:

find_element_by_xpath("//*[starts-with(@id,'ip_selection') and ends-with(@id,'name')]") 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks!!!! you are a great!!! I didn't know I could use contains... With that it works really well :D... thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.