How to execute Compound class names using web driver.

8,177 views
Skip to first unread message

sita maram

unread,
Jan 25, 2012, 3:27:02 AM1/25/12
to seleniu...@googlegroups.com
Hi All,

I have element like classname="x-form-field x-form-text x-form-invalid x-form-focus",i written code as below.

driver.findElement(By.className("x-form-field x-form-text x-form-invalid x-form-focus").sendkeys("Test123");

i got below error when i execute above statement ,please find below error i am getting.

FAILED: test
org.openqa.selenium.IllegalLocatorException: Compound class names are not supported. Consider searching for one class name and filtering the results.
Build info: version: '2.16.1', revision: '15405', time: '2012-01-05 12:23:54'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_24'
Driver info: driver.version: unknown
    at org.openqa.selenium.By.className(By.java:132)
    at com.eiq.scripts.Test12.test(Test12.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:758)
    at org.testng.TestRunner.run(TestRunner.java:613)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1142)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1067)
    at org.testng.TestNG.run(TestNG.java:979)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0


Please any one suggest on this.

--
Thanks and Regards,
M.Sitaramireddy.

Luke Inman-Semerau

unread,
Jan 25, 2012, 5:50:33 AM1/25/12
to seleniu...@googlegroups.com
You need to use a CssSelector in the format ".nameA.nameB.nameC" you can have as many as you'd like, just add the "."

Alternatively you can match the whole attribute (you can also do this with xpath): "*[class='exact class name here']"
XPath - "//*[@class='exact class name here']"

There are ways to do starts with or ends with or contains too (in both CSS and xpath). 

-Luke
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
Reply all
Reply to author
Forward
0 new messages