Closed Cryton1000 closed 9 years ago
Hi, thanks for the suggestion.
I've recently improved the variable name feature by searching for labels for the input in question (see issue #60) It doesn't always work well because sometimes people will make more than one label for the same input or use something like "Input format is xyz" as a label. I still hadn't used the "search for a label" strategy when suggesting xpath and you showed me the right way to do it. I'll try to adapt this to what's already in place.
Feel free to make to make more suggestions or report bugs.
I implemented this but restricting the scope of the search for a label to what I call the "nearest text element". Can be preceding, following or parent. Similar to what I did when searching for a variable name. It seems to produce better results, but it's hard to say because it depends on how a page is designed.
Also, I'll take the liberty of editing the issue name, so it's more clear on the release notes.
Suggestion for new locator strategy for label:
In my project we have a title input field like this:
With firerobot and label i get this locator: Input Text xpath=(.//div[contains(normalize-space(.),'Title')])[last()]/child::input[@type='text'] ${title}
In my c# webdriver project i have a extension for finding textfields with html like this: Driver.FindElement(By.XPath(".//*[@id=//label[normalize-space()='" + text + "']/@for]))
Robot: xpath=(.//*[@id=//label[normalize-space()='Title']/@for]) <- tested and confirmed working
http://www.w3schools.com/tags/att_label_for.asp http://www.w3schools.com/tags/tag_label.asp
/Austin
Keep up the good work you are doing! :)