Reputation: 17
Appium logs patch:
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":32,"value":"javax.xml.transform.TransformerException: Extra illegal tokens: ')', '[', '2', ']'"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 32 to InvalidSelectorError
[debug] [W3C (065be1bf)] Encountered internal error running command: InvalidSelectorError: javax.xml.transform.TransformerException: Extra illegal tokens: ')', '[', '2', ']'
Eclipse Code:
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//to click on specific object/position on a screen
driver.findElementByXPath("//android.widget.TextView[@text='Preference']").click();
driver.findElementByXPath("//android.widget.TextView[@text='3. Preference dependencies']").click();
//finding element by ID
driver.findElementById("android:id/checkbox").click();
//
driver.findElementByXPath("//android.widget.RelativeLayout)[2]").click();
driver.findElementByClassName("//android.widget.EditText").sendKeys("Hello");
driver.findElementsByClassName("android.widget.Button").get(1).click();
Till 3rd line, the code works and fine but at that, it stops and doesn't go to the next lines of code and shows the above error in Appium.
Upvotes: 0
Views: 299
Reputation: 4507
A bracket is missing in the line driver.findElementByXPath("//android.widget.RelativeLayout)[2]").click();
If you are going to the 2nd index using the xpath, you need to add a bracket before starting the xpath like:
driver.findElementByXPath("(//android.widget.RelativeLayout)[2]").click();
Also, in the next line you are using className, and if you are using any tag like id
or className
while identifying the element then //
is not used, so you need to change it to:
driver.findElementByClassName("android.widget.EditText").sendKeys("Hello");
else it will throw a NoSuchElementException
.
Upvotes: 2