1

I'm testing a GWT + SMARTGWT application and I'm trying to locate the elements of this web application using Selenium Webdriver. The method which I have used to locate the elements is by the relative XPath of those elements but the problem which I am currently facing is that this method is working correctly on the browsers like Chrome, Firefox, and Edge but not on the IE browser. The version of IE on my PC is 11.1593.14393.0. The IE browser is not able to find the element. I am also getting the following exception sometimes for other elements:

Exception in thread "main" org.openqa.selenium.InvalidSelectorException: Unable to locate an element with the xpath expression //img[contains(@src,'Insert XXX')] because of the following error: Error: Bad token: ]

I have tried the following methods for troubleshooting this issue but none of them worked out for me:

  • Enabling and disabling the enhanced protected mode for all the levels in IE browser.

  • Adding the URL of my webpage to the trusted capabilities.

  • Using the DesiredCapabilities method as suggested on the

  • AutomatedTesting page of the SmartGWT.

  • Setting a registry entry for IE browser in the PC.

  • Using JavaScriptExecutor to locate the elements.

  • Using the 32 bit IE driver instead of 64 bit.

Sadly, the IE browser is able to locate the elements on all the web pages except that belonging to my web application. Another problem which is troubling me is that none of the browser is able to locate the SMARTGWT element when I tried to find the element by ID. Also, the absolute XPath is working on every browser and that's why I went for the relative XPath method. What should I do to fix my issue? I want my code to run perfectly on all the browsers, but testing on this SmartGWT application has made my life hell.

  • 1 - There is missing closing parenthesis in //img[contains(@src,'Insert XXX']. 2 - Your're talking about relative xPath however this particular path seems startging from the top of the document. – Alexey R. Sep 8 '17 at 11:09
  • 1
    1. sorry, I forgot to add the closing parentheses in this post. I have edited the post now. But I have included this ) parentheses in my actual code. 2. Yes. I know this path will start from the top of the document but it is working fine on rest of the 3 browsers as mentioned in my post except the IE browser. – DG4 Sep 8 '17 at 11:15
  • So what you have provided is a precise message you're getting? I'm asking because bad token is a kind of parsing issue which breaks the grammar of the query. That might happen due to some special characters or whatver. But I cannot see any suspicious things here. (I mean the name of the attribute and the text are exactly the same as you have in your case?) – Alexey R. Sep 8 '17 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.