Workaround finding element with attribute name that includes a dash

35 views
Skip to first unread message

Ernest Micklei

unread,
Feb 24, 2012, 11:45:20 AM2/24/12
to watij
Hi,

In Html5 , attributes prefixed with "data-" can be used for various
libraries; jquery mobile is one of them.
However, finding elements using such an attribute currently (3.2.1)
does not work as expected:

spec.find("a").with("data-test", "newrule").click();

This is because the with query is composed as: elementForWatix.data-
test='newrule'
Here the "-" is interpreted as an operator in javascript ; the element
is never found.

A workaround is to rewrite the test statement like this:

spec.find("a").with("getAttribute('data-test') == 'newrule'").click();

Perhaps it is safer to use "getAttribute" all the time in
Tag>>doWith(String with, String nextListVar)
Reply all
Reply to author
Forward
0 new messages