Programmer Programmer - 3 years ago 96
Python Question

get content using partial text in p tag keyword in python selenium

Here is my code. I want to get text content of Product name which is only "IDE" not " Product name: IDE".

<div class="typeCategory">
<p class="Type" >
"
Product name: IDE
"
<br>

"
Product Price: $499
"

</p>


Can anyone tell me how?
Thanks!

Answer Source

This should get you closer to what you are trying to do:

element = driver.find_element_by_xpath("//*[contains(text(), 'Product name')]")
product = element.text.replace("Product name: ", "")

Hope this helped!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download