Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

get_attribute method doesn't work on Python with Selenium

$
0
0

So, I'm having trouble getting a element from a web page with Selenium and Python

The div in question is:

<div class="col-sm-6 col-lg-4 broker-details"><div class=" "><h6>MICHAEL CORLEONE</h6><div> <strong>CODE: </strong> <span> 123456-X</span> </div><div> <strong>Registration Date: </strong><span>18/03/2021</span> </div><div> <strong>Situation: </strong><span>Active</span> </div><form action="/citizen/details" method="post"><input type="hidden" name="registerNumber" value="123456-X"><button class="btn btn-primary" type="submit"> See More </button></form></div></div>

when I use find_elements() to return the class elements as:

#setting the driverdriver = webdriver.Chrome(service=service, options=options)driver.find_elements(By.CLASS_NAME, 'broker-details')[0].text

it returns something like:

'MICHAEL CORLEONE\nCODE: 123456-X\nRegistration Date: 18/03/2021\nSituation: Active\nSee More'

but when I try to use get_attribute to get a specific element, like:

driver.find_elements(By.CLASS_NAME, 'broker-details')[0].get_attribute('span')

it returns nothing, should I be referencing the blank space class? didn't even know it was possible, is there something im missing? I don't really know much about html/css/python please help.


Viewing all articles
Browse latest Browse all 13951

Trending Articles