Announcement

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

    Selenium.doubleClick() does not work with Firefox

    Hi,

    I have the following sample application:
    Code:
    public class SeleniumSupportSample implements EntryPoint {
    
        public void onModuleLoad() {
            DynamicForm form = new DynamicForm();
            form.setID("Form");
            
            final StaticTextItem staticTextItem = new StaticTextItem("staticTextItem");
            staticTextItem.setShowTitle(false);
            staticTextItem.setValue("Before Click");
            
            ButtonItem buttonItem = new ButtonItem("buttonItem", "Button Item");
            buttonItem.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    Log.info("The button item has been clicked");
                    staticTextItem.setValue("After click");
                }
            });
            
            final StaticTextItem staticTextItem2 = new StaticTextItem(
                    "staticTextItem2");
            staticTextItem2.setShowTitle(false);
            staticTextItem2.setValue("Before double-click");
            ButtonItem buttonItem2 = new ButtonItem("buttonItem2", "Button Item 2");
            buttonItem2.addDoubleClickHandler(new DoubleClickHandler() {
                public void onDoubleClick(DoubleClickEvent event) {
                    Log.info("The button item2 has been double clicked");
                    staticTextItem2.setValue("After double-click");
                }
            });
            buttonItem2.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    Log.info("The button item2 has been clicked");
                }
            });
            
            form.setFields(staticTextItem, buttonItem, staticTextItem2, buttonItem2);
            
            form.show();
        }
    
    }
    And this is the class to test the sample application using Selenium
    Code:
    public class SeleniumSample {
        
        private static final Logger m_log = Logger.getLogger(SeleniumSample.class);
    
        /**
         * @param args
         * @throws Exception 
         */
        public static void main(String[] args) throws Exception {
            
            SeleniumServer server = null;
            Selenium selenium = null;
            
            try {
                RemoteControlConfiguration config = new RemoteControlConfiguration();
                config.setUserExtensions(new File("user-extensions.js"));
                server = new SeleniumServer(config);
                
                server.boot();
                m_log.info("The server has been started");
                
                HttpCommandProcessor processor = new HttpCommandProcessor("localhost",
                        4444,
                        "*firefox",
                        "http://localhost:7001/SeleniumSupportSample/SeleniumSupportSample.html");
                
                selenium = new DefaultSelenium(
                         processor);
                selenium.start();
                selenium.open("http://localhost:7001/SeleniumSupportSample/SeleniumSupportSample.html");
                m_log.info("The browser window has been opened");
                
                m_log.info("The label text is = '" + selenium.getText("scLocator=//DynamicForm[ID=\"Form\"]/item[name=staticTextItem]/textbox") + "'");
                m_log.info("The button title is '" + selenium.getText("scLocator=//DynamicForm[ID=\"Form\"]/item[name=buttonItem]/canvas/title") + "'");
                selenium.click("scLocator=//DynamicForm[ID=\"Form\"]/item[name=buttonItem]/canvas/");
                m_log.info("The button item has been clicked");
                m_log.info("The label text is = '" + selenium.getText("scLocator=//DynamicForm[ID=\"Form\"]/item[name=staticTextItem]/textbox") + "'");
                m_log.info("The label2 text is = '" + selenium.getText("scLocator=//DynamicForm[ID=\"Form\"]/item[name=staticTextItem2]/textbox") + "'");
                
                selenium.doubleClick("scLocator=//DynamicForm[ID=\"Form\"]/item[name=buttonItem2]/canvas/");
                m_log.info("The button item2 has been double-clicked");
                m_log.info("The label2 text is = '" + selenium.getText("scLocator=//DynamicForm[ID=\"Form\"]/item[name=staticTextItem2]/textbox") + "'");
               
                Thread.sleep(5000L);
            } finally {
                if (selenium != null) {
                    selenium.deleteAllVisibleCookies();
                    selenium.stop();
                }
                
                if (server != null) {
                    server.stop();
                }
            }
        }
    }
    The issue itself is that if I deploy the sample application and run the SeleniumSample then I get the following output from SeleniumSample (the last 3 lines):
    "The label2 text is = 'Before double-click'
    The button item2 has been double-clicked
    The label2 text is = 'Before double-click'".
    The output of the application itself is (last 2 lines):
    "The button item2 has been clicked
    The button item2 has been clicked"
    So the output of SeleniumSample and of the application itself shows that the "double-click" event has NOT been trigerred.

    But if I switch to Internet Explorer (make HttpCommandProcessor to use "*iexplore" instead of "*firefox") then the double-click event IS trigerred.
    The output from SeleniumSample is (last 3 lines):
    "The label2 text is = 'Before double-click'
    The button item2 has been double-clicked
    The label2 text is = 'After double-click'"
    And the output of the application itself (last 2 lines):
    "The button item2 has been clicked
    The button item2 has been double clicked"

    Also when I tried to perfrom the double-click manually in FF then everything works fine. The label got updated and I got the application output:
    "The button item2 has been clicked
    The button item2 has been double clicked"


    Can you please let me know if it is a bug in the support of Selenium for SmartGWT or did I miss something?

    My environment information is:
    - Operating system: Windows XP SP3
    - Browsers: IE 7 and FF 3.6.3
    - SmartGWT: 2.2
    - GWT: 2.0.3

    Regards,
    Iurii
    Last edited by iurii; 10 Jun 2010, 07:22.

    #2
    The related issue is with the Selenium IDE:
    It records 2 clicks instead of double-click.

    If you try to record double-click on the "button item2" the recording produced by the Selenium IDE will be the following:
    Code:
    selenium.open("/SeleniumSupportSample/SeleniumSupportSample.html");
    selenium.click("scLocator=//DynamicForm[ID=\"Form\"]/item[name=buttonItem2||title=Button%20Item%202||index=3||Class=ButtonItem]/canvas/");
    selenium.click("scLocator=//DynamicForm[ID=\"Form\"]/item[name=buttonItem2||title=Button%20Item%202||index=3||Class=ButtonItem]/canvas/");
    Please let me know if the behavior described in these two posts is expected or it is a bug

    Regards,
    Iurii

    Comment


      #3
      Is there a way to solve the problem of double click on the tree node?

      Comment


        #4
        I've opened the respective issue http://code.google.com/p/smartgwt/issues/detail?id=514

        Comment

        Working...
        X