Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Unable to locate the elements of SmartGWT application using Selenium in IE browser

    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 and then click on them is by using 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:
    Code:
    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 click on the elements.
    Sadly, the IE browser is able to click on 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 combined with IE has made my life hell.
    Last edited by DG4; 8th Sep 2017, 03:08.

  • #2
    Read the Automated Testing overview. You shouldn't be using xpaths - you should be using scLocator strings.

    Comment


    • #3
      Actually I have followed everything mentioned on the Automated Testing page and also finding the scLocators in the IDE as mentioned on this page: https://www.smartclient.com/smartgwt...gSelenium.html. The Selenium IDE was successful in finding the scLocators strings of my web application. But after recording the whole test case, when I tried to play that test case, the Selenium IDE was not able to find the scLocators found by the itself a minute ago and I found it very strange. Moreover, when I used the scLocators in WebDriver, the same problem occurred once again and I was getting the NoSuchElementException each time since the WebDriver was also not able to find the scLocators and that's why I rejected the idea of using scLocators and used Relative XPaths instead. Can you please tell me what will be the solution for this issue?

      Comment


      • #4
        We're currently running about 50,000 individual tests a day based on our scLocator support, so it's not broken.

        You could get this kind of problem through user error (eg test page differs from recording page), or by not using the versions we specify in the docs. Start with some basic troubleshooting, and if you get stuck, provide all the required information to make the problem reproducible.

        Comment


        • #5
          Well I followed what you said and I read what's written on Automated Testing and Using Selenium many times and I observed that I was using a slightly different approach. I stopped using the scLocators through WebDriver. Instead, I recorded the test case using the Selenium IDE on my web application and then I saved the test case and test suite as HTML files. Then, I tried to run the test on the Command Line using Selenium Standalone server but got the following error:

          Code:
          D:\SELENIUM>java -jar D:\SELENIUM\selenium-server-standalone-3.5.3.jar -htmlSuite "*firefox" "http://xxx.xxx.xxx" "D:\selenium\mytestsuite.html" "D:\selenium\mytestresult.html"
          Unable to find the HTML runner. This is normally because you have not downloaded
          or made available the 'selenium-leg-rc' jar on the CLASSPATH. Your test will
          not be run.
          Download the Selenium HTML Runner from http://www.seleniumhq.org/download/ and
          use that in place of the selenium-server-standalone.jar for the simplest way of
          running your HTML suite.
          Then, I downloaded the HTML Runner and run the test again but this time I got the following error:
          Code:
          D:\SELENIUM>java -jar D:\SELENIUM\selenium-html-runner-3.5.3.jar -htmlSuite "*firefox" "http://xxx.xxx.xxx" "D:\selenium\mytestsuite.html" "D:\selenium\mytestresult.html"
          Multi-window mode is longer used as an option and will be ignored.
          1505299367134   geckodriver     INFO    geckodriver 0.18.0
          1505299367140   geckodriver     INFO    Listening on 127.0.0.1:15805
          1505299367821   geckodriver::marionette INFO    Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"]
          1505299369478   Marionette      INFO    Listening on port 62599
          Sep 13, 2017 4:12:49 PM org.openqa.selenium.remote.ProtocolHandshake createSession
          INFO: Detected dialect: W3C
          2017-09-13 16:12:49.967:INFO::main: Logging initialized @3531ms to org.seleniumhq.jetty9.util.log.StdErrLog
          2017-09-13 16:12:50.019:INFO:osjs.Server:main: jetty-9.4.z-SNAPSHOT
          2017-09-13 16:12:50.070:INFO:osjsh.ContextHandler:main: Started o.s.j.s.h.ContextHandler@65d09a04{/tests,null,AVAILABLE}
          2017-09-13 16:12:50.126:INFO:osjs.AbstractConnector:main: Started ServerConnector@7129495a{HTTP/1.1,[http/1.1]}{0.0.0.0:27160}
          2017-09-13 16:12:50.140:INFO:osjs.Server:main: Started @3704ms
          2017-09-13 16:12:50.516:INFO:osjs.AbstractConnector:main: Stopped ServerConnector@7129495a{HTTP/1.1,[http/1.1]}{0.0.0.0:27160}
          2017-09-13 16:12:50.517:INFO:osjsh.ContextHandler:main: Stopped o.s.j.s.h.ContextHandler@65d09a04{/tests,null,UNAVAILABLE}
          1505299370522   Marionette      INFO    New connections will no longer be accepted
          Sep 13, 2017 4:12:50 PM org.openqa.selenium.server.htmlrunner.HTMLLauncher mainInt
          WARNING: Test of browser failed: *firefox
          com.thoughtworks.selenium.SeleniumException: Unknown command: waitForElementClickable
                  at org.openqa.selenium.server.htmlrunner.CoreTestCase.findCommands(CoreTestCase.java:134)
                  at org.openqa.selenium.server.htmlrunner.CoreTestCase.run(CoreTestCase.java:62)
                  at org.openqa.selenium.server.htmlrunner.CoreTestSuite.run(CoreTestSuite.java:73)
                  at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:121)
                  at org.openqa.selenium.server.htmlrunner.HTMLLauncher.mainInt(HTMLLauncher.java:247)
                  at org.openqa.selenium.server.htmlrunner.HTMLLauncher.main(HTMLLauncher.java:275)
          Firefox launched for just less than a second and was closed automatically when I was using the HTMLRunner. So, I am just clueless right now on how to automate this web application using your scLocators method. I think that the relative XPath method is much better than this method because using ScLocators, I am unable to find anything in the application. But the relative Xpath method was working fine in Chrome, Firefox, and Edge except in the IE. So, I request you to please help me to automate my web application. Here is the detail of the versions of different tools which I am using.
          • The GWT application itself has the SmartGWT 5.0 LGPL edition.
          • I imported the User Extension Javascript files of SmartGWT 5.0 in Selenium IDE.
          • Selenium IDE version: 2.9.1
          • Selenium HTML Runner version: 3.5.3
          • Firefox version: 54.0.1 (32-bit)
          • OS: Windows 10 (64 bit)
          • Selenium Standalone server version: 3.5.3

          Comment


          • #6
            We ship specific versions of Selenium to use for a reason - use those.

            Just to reiterate: your idea of using XPath expressions is 100% a dead end, because the DOM generated by SmartClient components is undocumented and subject to change at any time. We are constantly adjusting the DOM we use on different platforms to work around various browser bugs. XPath-based tests would break due to DOM changes, scLocators will not.

            Meanwhile, again, we run tests based on scLocators constantly. It's a very robust system, once you follow the docs.

            Comment

            Working...
            X