Announcement

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

    SmartClientFirefoxDriver click() method fails

    We are trying to set up a Selenium test using SmartClientFirefoxDriver to click an expandable node in a TreeGrid and have jUnit assert that the expanded value is found on the page. We seem to be having a problem specifically with the click() method on the SmartClient Firefox driver. I’ve also tried the click method on an ScAction object and that doesn’t seem to work for expanding a tree node either. As a workaround I tried using doubleClick() and it worked using the TreeGrid on your page but I couldn't seem to get it to work in our code (without using both .click() and .doubleClick() on the same element). I would prefer to just single click to expand/collapse the tree. Do you have any suggestions for expanding a node in a TreeGrid using web driver?

    Here is my information and code that I am using:

    We are using SmartClient version v9.1p_2014-06-26/Pro Development Only with Selenium version 2.37.1. I ran my test with SmartClientFirefoxDriver and Firefox 23 (also tried with Firefox 17). I also tried the test with SmartClientChromeDriver and Chrome version 35.0. I am running Mac OS X 10.9.3

    SmartClient Developer Console Log:
    Code:
    12:54:54.755:DEBUG:AutoTest:employeeTree_body:AutoTest.getElement(): locator substring:row[EmployeeId=4||Name=Charles%20Madigen||0] parsed to fallback locator name:row, unable to find relevant child - may refer to inner element.
    12:54:54.756:DEBUG:autotest:employeeTree:Trying to locate row by pk
    12:54:54.756:DEBUG:autotest:employeeTree:Located row 0 by pk
    12:54:54.840:MDN8:INFO:EventHandler:Target Canvas for event 'mousedown': [TreeGridBody ID:employeeTree_body]
    12:54:54.849:MDN8:INFO:nativeFocus:employeeTree_body:about to call native focus()
    Canvas.setFocus(_1=>true, _2=>"focus on mousedown")
    [a]MathFunction.invokeSuper(_1=>null, _2=>"setFocus", _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef, _11=>undef, _12=>undef, _13=>undef)
    [a]MathFunction.Super(_1=>"setFocus", _2=>[object Arguments], _3=>undef)
    GridRenderer.setFocus(_1=>true, _2=>"focus on mousedown")
    Canvas.focus(_1=>"focus on mousedown")
    [c]EventHandler._$observed_doHandleMouseDown(_1=>[object MouseEvent], _2=>undef)
    doHandleMouseDownObservation([object MouseEvent], undef)
    [c]EventHandler.handleMouseDown(_1=>[object MouseEvent], _2=>undef)
    [c]EventHandler.dispatch(_1=>[c]EventHandler.handleMouseDown(), _2=>[object MouseEvent])
    anonymous(event=>[object MouseEvent])
    
    12:54:54.850:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[TreeGridBody ID:employeeTree_body]' has handler: Canvas.prepareForDragging()
    12:54:54.850:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[TreeGrid ID:employeeTree]' has handler: Canvas.prepareForDragging()
    12:54:54.850:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[Canvas ID:featureExplorer_exampleViewer_exampleViewPane_viewContainer]' has handler: Canvas.prepareForDragging()
    12:54:54.850:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[ExampleViewPane ID:featureExplorer_exampleViewer_exampleViewPane]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[PaneContainer ID:featureExplorer_exampleViewer_paneContainer]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[ExampleViewer ID:featureExplorer_exampleViewer]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[SectionStack ID:featureExplorer_examplePage]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[Canvas ID:featureExplorer_centerPane]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[HLayout ID:featureExplorer_leftSuperPane]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[HLayout ID:featureExplorer_topPane]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Bubbling event 'prepareForDragging', target '[FeatureExplorer ID:featureExplorer]' has handler: Canvas.prepareForDragging()
    12:54:54.851:MDN8:DEBUG:EventHandler:Event 'prepareForDragging' bubbled to top
    12:54:54.851:MDN8:DEBUG:dragDrop:No dragTarget, not dragging
    12:54:54.852:MDN8:DEBUG:Selection:employeeTree_selection:selectOnMouseDown: recordNum: 0
    12:54:54.859:MDN8:INFO:aria:ARIA state: selected: true, set on element: [TRElement]{nodeName:TR}
    12:54:54.859:MDN8:DEBUG:EventHandler:Event 'mouseDown' bubbled to top
    12:54:54.863:MDN8:INFO:EventHandler:Target Canvas for event 'undefined': [TreeGridBody ID:employeeTree_body]
    12:54:54.870:MUP9:INFO:EventHandler:Target Canvas for event 'mouseup': [TreeGridBody ID:employeeTree_body]
    12:54:54.873:MUP9:DEBUG:Selection:employeeTree_selection:selectOnMouseUp: recordNum: 0
    12:54:54.873:MUP9:DEBUG:EventHandler:Event 'mouseUp' bubbled to top
    12:54:54.875:MUP9:DEBUG:EventHandler:Event 'click' bubbled to top
    12:54:54.947:TMR1:DEBUG:EventHandler:mousing over [TreeGridBody ID:employeeTree_body]
    12:54:56.833:MOU4:DEBUG:Label:isc_Label_0:setRect: {left: 0,
    top: -1000,
    width: undef,
    height: undef}
    12:54:56.835:MOU4:DEBUG:Label:isc_Label_0:setRect: {left: 0,
    top: -1000,
    width: undef,
    height: undef}
    Code that I am running:
    Code:
    package test;
    
    import static org.junit.Assert.assertEquals;
    
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    
    import com.isomorphic.webdriver.ByScLocator;
    import com.isomorphic.webdriver.SmartClientFirefoxDriver;
    
    public class SmartClientTreeClickTest {
    
    	@Test
    	public void testClick() {
    
    		SmartClientFirefoxDriver driver = new SmartClientFirefoxDriver();
    
    		driver.setBaseUrl("http://localhost:8080/");
    		driver.get("isomorphic/system/reference/SmartClient_Explorer.html#nodeTitles");
    		driver.manage().window().maximize();
    
    		By treeExpander =
    				ByScLocator.scLocator("//testRoot[]/child[Class=TreeGrid||index=0||length=1||classIndex=0"
    						+ "||classLength=1||roleIndex=0||roleLength=1||scRole=tree]/body/row[EmployeeId=4"
    						+ "||Name=Charles%20Madigen||0]/col[fieldName=Name||0]/open");
    
    		driver.waitForElementClickable(treeExpander);
    		driver.click(treeExpander);
    
    		By expandedRowTitle =
    				ByScLocator.scLocator("//testRoot[]/child[Class=TreeGrid||index=0||length=1||classIndex=0"
    						+ "||classLength=1||roleIndex=0||roleLength=1||scRole=tree]/body/row[EmployeeId=182"
    						+ "||Name=Tamara%20Kane||1]/col[fieldName=Name||0]");
    
    		driver.waitForElementClickable(expandedRowTitle);
    		WebElement actualValue = driver.findElement(expandedRowTitle);
    
    		assertEquals("Mgr Site Services: Tamara Kane", actualValue.getText());
    
    		driver.close();
    		driver.quit();
    	}
    
    }

    #2
    We've reproduced the issue and are preparing a solution.

    Comment


      #3
      A fix was applied for SC 10.0d/9.1p. Your script should be working now. Check the next nightly builds.

      Comment


        #4
        Thanks, it looks like your recent release resolved the problem. When I click on a tree grid element and use /open on the scLocator it will now expand the tree grid node.

        Comment


          #5
          It looks like the .click() method is working in most cases however every now and then we get into a situation where waitForGridDone or waitForElementClickable waits endlessly. The element or grid is clearly visible on the page so it just looks like the wait method is not rechecking the page. The problem appears to be intermittent.

          It is difficult to replicate the issue but I was wondering if you had any insight on how to troubleshoot an issue like this. Is there a way to get waitForGridDone or waitForElementClickable to time out after a certain amount of time? Could it be a bad scLocator? I’ve verified the scLocator with the Smart Client console and it looks correct. My guess is that the element is somehow not found and gets stuck waiting endlessly. If I can get the wait method to time out I can put in a check to try again before failing the test.

          Comment


            #6
            It's unlikely that stopping and recalling waitForElementClickable() will solve the problem - the Selenium waitForXXX() logic repeatedly calls the underlying isXXX() API until it times out or the condition becomes true. Some ideas:

            You said you've already checked that the scLocator is valid. So does isc.AutoTest.getObject(<scLocator>) return the canvas in question?

            Can you try updating to current versions of the Selenium JARs (from the Selenium website)? The current version is 2.42 or higher.

            You earlier mentioned different browsers. Does the problem happen in both of them? FF23 is an old version. Can you try to reproduce the issue in FF24 ESR, which is still current? (Or FF31?)

            Lastly, you could set the "testReplay" logger from the dev console to be at INFO level; this should provide more information. You could also look at the checks performed by AutoTest.isElementClickable() in the modules-debug directory of your SDK and manually call each of those checks on the canvas to determine what is failing.
            Last edited by Isomorphic; 19 Aug 2014, 07:43.

            Comment


              #7
              If one of the suggestions fixed the problem, please let us know as it will allow the documentation and future troubleshooting to be improved.

              Comment


                #8
                Thank you for the follow up. I double checked my scLocators using isc.AutoTest.getObject() and they all appear to be valid.

                We are running our WebDriver tests in both version 23.0.1 and 24.5.0 of Firefox. The problem appears to be happening more often in Firefox version 24.5.0. However, according to the Selenium changelog either of these versions of Firefox should work for Selenium version 2.37.1

                In any case, I think its about time we upgrade to 2.42 and get the browsers up to date. As soon as I get a chance to do this I will follow up with the results. Thanks

                Comment


                  #9
                  Sorry to bring back an old post but we have been looking into this issue again and we were finally able to upgrade Selenium to 2.43.1 and FireFox to 32.

                  It looks like we are still seeing the race condition where the waitForElementClickable check is not actually waiting. Every now and then we get a NoSuchElementException because WebDriver thinks the element is not there even though it is clearly visible. I've put some manual checks to retry the page several times before erroring out but it seems like waitForElementClickable should in fact wait until the element is ready.

                  Any further tips on this?

                  Thank you.

                  Comment


                    #10
                    It looks like you ran through most of the tips we already provided, except the last one:

                    Lastly, you could set the "testReplay" logger from the dev console to be at INFO level; this should provide more information. You could also look at the checks performed by AutoTest.isElementClickable() in the modules-debug directory of your SDK and manually call each of those checks on the canvas to determine what is failing.

                    Comment


                      #11
                      I went ahead and turned on testReplay but unfortunately didn't see much come through the smartclient console.

                      I used AutoTest.isElementClickable() on my sc locator and was able to get 'true' every time. It looks like something with waitForElementClickable is allowing the object through even though it is not quite ready to be clicked.

                      To follow up on running some of the checks in the modules-debug directory could you possibly elaborate on that? I see in my modules-debug directory I have ISC_Core.js, ISC_Analytics.js etc...

                      ISC_Core.js appeared to be the only file that contained any information about AutoTest and isElementClickable(). Do I somehow run this script against my locator? Is there a way to do this from the console?

                      Thank you again for your help.

                      Comment


                        #12
                        Presumably there is a point in your test where waitForElementClickable has allowed the test to proceed, yet isElementClickable is (surprisingly) still false. Anything else would be correct behavior.

                        If you can capture "testReplay" logs from that situation, we might be able to analyze those and see something.

                        Or, as previously suggested, you yourself can look at the code of isElementClickable and see how it could be returning false even if waitForElementClickable has just allowed the test to proceed.

                        Comment

                        Working...
                        X