Reputation: 191
I'm using find_elementS_by_xpath I got a list successfully mapped to the price varibale and I would like to print that out. I know I have iterate through since its a list however the actual text of the xpath doesn't want to print properly:
my code:
price = driver.find_elements_by_xpath("//div[@class='price']")
for x in range (len(price)):
print(price[x])
driver.quit()
results are these instead of the actual text:
<selenium.webdriver.remote.webelement.WebElement (session="45e318bd282a63442a83df978a1aa85d", element="bbfc9091-7332-4ca4-8480-7ace07ea5cbb")>
<selenium.webdriver.remote.webelement.WebElement (session="45e318bd282a63442a83df978a1aa85d", element="3db3e802-ac72-4dd1-8a3e-748950082f10")>
<selenium.webdriver.remote.webelement.WebElement (session="45e318bd282a63442a83df978a1aa85d", element="01cbbcf5-413e-4817-aaef-e4f70655a7fa")>
<selenium.webdriver.remote.webelement.WebElement (session="45e318bd282a63442a83df978a1aa85d", element="7e4132f7-21ca-4364-b462-7ef9b4ffe0c4")>
<selenium.webdriver.remote.webelement.WebElement (session="45e318bd282a63442a83df978a1aa85d", element="511435cb-d259-4f78-bddb-9ceb2f666636")>
Upvotes: 1
Views: 11915
Reputation: 81
You could use getText() to display the value:
List<WebElement> price = driver.find_elements_by_xpath("//div[@class='price']");
for(WebElement x : price)
print(x.getText());
Upvotes: 0
Reputation: 33384
Use .text
to print the value.
price = driver.find_elements_by_xpath("//div[@class='price']")
for x in range (len(price)):
print(price[x].text)
driver.quit()
Upvotes: 4