selenium - Webdriver - Locate Input via Label (Python) -


How can I find the input field through my label using the WebDriver?

I use an ID generated in a certain malicious way, so they are inappropriate as identifiers.

Nevertheless, the label associated with each web element kills me as a good. Unfortunately I was not able to do this with some of the suggestions given on the web. There is a thread here, but the accepted answer is not found:

In order to solve this problem in Java, it is usually labeled through an anchor It is suggested to apply the contents of its text and then specify the expat in the input element:

  // label [in it (text (), 'TEXT_TO_FIND']]   

I'm not sure how to do this in dragon. My web element:

  & lt; Div class = "InputText" & gt; & Lt; == Labels for = "INPUT" & gt; & Lt; Period & gt; Label text & lt; / Span & gt; & Lt; Span id = "idd" square = "required" heading = "required" & gt; * & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; Span class = "text" & gt; & Lt; Input id = "INPUT" class = "Text ColoredFocus" type = "text" onchange = "var wcall = wicket agextpost ('; jsessionid = ...;" maxlength = "30" name = "z1013400259" value = "" & << input gt; & lt; / span & gt; & lt; div class = "required labels" & gt;? & lt; / div & gt; & lt; span & gt; one ??    

My problem The only solution I found was that dirty - parsing the source code of the page and string o It was definitely not the purpose of using the WebDrive, but it works very strong.

Code:

  line = [] For line in the driver. Page_source.splitlines (): lines.append (line) in the 'Label Text 1' line: id_l1 = lines [-2] .split ('' ', 2) [1]    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -