I'm hoping I can get some help as I have tried many iterations of code thus far.
My goal is to extract what today appears to be $0.00 in the below screenshot:
The associated elements appear as such:
<span >$0.00</span>
XPATH:
/html/body/div[4]/div/div/div[2]/div[1]/div[2]/div/div[2]/div/div[1]/div/div/div[2]/div[2]/span
CSS Selector:
div.rem-padd > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > span:nth-child(1)
CSS Path:
html body.ng-scope div#centerContentDiv div.ng-scope div.container.ng-scope div.row div.col-sm-12.col-md-6 div.panel-group div.panel.panel-default div.panel-body div div.bill-info-table div.col-xs-12.col-sm-12.col-md-12.col-lg-12.rem-padd div.col-xs-12.col-sm-12.col-md-12.col-lg-12 div.row div.col-xs-12.col-sm-12.col-md-6.col-lg-8.account-summery-data.account-summery-datawithbtn.padding-rightzero span.span-title.surfaceclass.ng-binding
Here is my current code:
water_due = driver.find_elements((By.XPATH, '/html/body/div[4]/div/div/div[2]/div[1]/div[2]/div/div[2]/div/div[1]/div/div/div[2]/div[2]/span'))
for value in water_due:
print(value.text)
This code isn't working and I am getting the following error:
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: 'using' must be a string
I've tried several iterations of my code above using class, xpath, css selector, etc and I have not been successful.
I got it to work on another website and essentially what I want is for a value to hold the $0.00. Next month this will have another value so for example, the code at the end would print say: $34.58
which is currently displayed as $0.00
on the website.
Any help is appreciated!
I was successful in passing this same logic in a different website and that code looks like so:
electric_Due = driver.find_elements(By.XPATH, '/html/body/div[3]/div/div[2]/div/div[1]/div[1]/div[1]/div/div[2]/p[1]')
for value in electric_Due:
print(value.text)
Not sure why the current one is not working.
Thanks a lot!
CodePudding user response:
The problem lies in how you're calling this:
water_due = driver.find_elements((By.XPATH, '/html/body/div[4]/div/div/div[2]/div[1]/div[2]/div/div[2]/div/div[1]/div/div/div[2]/div[2]/span'))
If you use two sets of parens, you're constructing a tuple and passing it as the first argument. Selenium expects the first argument to the the By.XPATH
part.
So I would change it to this:
water_due = driver.find_elements(By.XPATH, '/html/body/div[4]/div/div/div[2]/div[1]/div[2]/div/div[2]/div/div[1]/div/div/div[2]/div[2]/span')