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 that I am running:
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:
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(); } }
Comment