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

Product Price: $499


Can anyone tell me how?

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