Priyanka Tester
Priyanka Tester

Reputation: 25

run 3 variables in for loop python selenium web-driver to print all data including links

I try to get the current price, company name, and company (link-text) links in for loop using Python in selenium web-driver. this is my URLhttp://demo.guru99.com/test/web-table-element.php

company = driver.find_elements_by_xpath("//*[@id='leftcontainer']/table/tbody/tr/td/a")
price = driver.find_elements_by_xpath("//*[@id='leftcontainer']/table/tbody/tr/td[4]")
link = driver.find_elements_by_xpath("//*[@id='leftcontainer']/table/tbody/tr/td/a")
for name,rate,links in zip(company,price.link):
    names = name.text
    rates = rate.text
    url = links.get_attribute("href")
    if float(rates) <= 500:
        print(names,rates,url)

and it's showing error:

AttributeError: 'list' object has no attribute 'link'

please help me to print rates, company names, and links.

Upvotes: 0

Views: 72

Answers (1)

Rami Janini
Rami Janini

Reputation: 593

You put .insead of , inside the zip, here is how you fix it for name,rate,links in zip(company,price,link):

Upvotes: 1

Related Questions