Skip to content
Advertisement

How to get the for attribute of label element using selenium

Am trying to use Python for the first time, and working on Selenium.

Goal is to get the ID of the Input element. Am trying to work with a page that generates random ID for Input element. So cannot address that element by ID. How ever i found that the element has a label, and the label says For=”<Dynamic_ID_Of_Input>”

And it so happens the label has no other attribute either.

Here’s what the page looks like

JavaScript

Here’s what I have managed so far:

JavaScript

the print output looks like this:

JavaScript

Am not able to figure out what is missing here. Appreciate all help.

Thank You

Advertisement

Answer

Please try this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement