One suggestion for ById() method of WebDriver

45 views
Skip to first unread message

Sudhansu Sekhar panda

unread,
May 4, 2015, 8:02:36 PM5/4/15
to selenium-...@googlegroups.com
Hi All,

I have a suggestions to the the below methods. 

We are facing one issue while inspecting the element having ID or xpaths etc in uppercase and lowercase. 

For example the ID is "employee-Details" and if we write our code by mistake By.id("employee-details") then it will fail as IDs are case sensitive. So what I am suggesting is if we can update the ById() method which will return the ID in lowercase always to avoid any error by adding toLowerCase() method like below.

public ById(String id) {
      this.id = id.toLowerCase();
    }.


Note: Its just a suggestion :)

Thanks,

Sudhansu

Andreas Tolfsen

unread,
May 5, 2015, 6:53:21 AM5/5/15
to selenium-...@googlegroups.com
On 23 Apr 2015, at 12:26, Sudhansu Sekhar panda <sudhans...@gmail.com> wrote:
> For example the ID is "employee-Details" and if we write our code by mistake By.id("employee-details") then it will fail as IDs are case sensitive. So what I am suggesting is if we can update the ById() method which will return the ID in lowercase always to avoid any error by adding toLowerCase() method like below.

ID attributes are not only case-sensitive, they are the unique identifiers of the DOM, which means "foo" is different from "Foo":

https://dom.spec.whatwg.org/#concept-id

This selector feature in particular should mirror the web platform.

David

unread,
May 5, 2015, 11:03:24 PM5/5/15
to selenium-...@googlegroups.com
and you could always wrap calling By.id() with your own methods that will lowercase the locator value before passing in to the actual By.id() method. and your proposal could be a problem in the reverse case where another group/user needs upper case, camelCase, or other pattern instead.

David Lai

unread,
May 9, 2015, 10:11:59 AM5/9/15
to selenium-...@googlegroups.com
I think it might be a better to add a html lint or tidy to enforce naming standards on the dev side to make sure they name their ID's consistently.

I think test engineers shouldn't bend over backwards for bad code, but we also have to make it easier for developers to write good code.
Reply all
Reply to author
Forward
0 new messages