Announcement

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

    Recorded script + Selenium RC

    Hi,
    When recording a Selenium script with the Selenium IDE in Firefox, a click on the SectionStack gets registered with the following scLocator:
    Code:
    //Window[ID="isc_Window_0"]/item[0][Class="SectionStack"]/section[index=3]/background/
    However, when executing this in the Selenium RC, this does not work.
    When the scLocator is edited to
    Code:
    //Window[ID="isc_Window_2"]/item[0][Class="SectionStack"]/section[index=3]/background/
    it does work....
    This should not have to be changed. See the screen shots for more information.
    Thank you!
    Attached Files

    #2
    Avoid auto-generated IDs (like "isc_Window_0") appearing in your test scripts. These are assigned in creation order, which may not be deterministic when components are created eg after network turnarounds. Use setID() to provide explicit IDs.

    Comment


      #3
      Ok, we will try to assign some ids. But we had some issues before with that.
      Say you have a menu that opens a tab with the exact same content.
      (Each tab starts with a search panel, before content specific information is shown)
      When you open a second tab you get errors complaining about: "
      Cannot change configuration property 'ID' to buttonID after the component has been created."
      So in this case we have to use the generated ids?

      Example:
      Code:
      private int count = 0;
      	public void onModuleLoad() {
      		final TabSet topTabSet = new TabSet();
      		topTabSet.setID("tabsetID");
      		topTabSet.setTabBarPosition(Side.TOP);
      		topTabSet.setTabBarAlign(Side.RIGHT);
      		topTabSet.setWidth(400);
      		topTabSet.setHeight(200);
      
      		Button button = new Button("Add Tab");
      		button.setID("addtabID");
      		button
      				.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
      					public void onClick(ClickEvent event) {
      						topTabSet.addTab(createNewTab());
      					}
      				});
      
      		VLayout vLayout = new VLayout();
      		vLayout.setMembersMargin(15);
      		vLayout.addMember(topTabSet);
      		vLayout.addMember(button);
      		vLayout.setHeight("auto");
      
      		vLayout.draw();
      	}
      
      	private Tab createNewTab() {
      		Tab tab = new Tab("TabNr-" + (count++));
      		tab.setID("tabID");
      		Button button = new Button("test");
      		button.setID("buttonID");
      		tab.setPane(button);
      		return tab;
      	}
      Java Stacktrace:
      Code:
      java.lang.IllegalStateException: Cannot change configuration property 'ID' to buttonID after the component has been created.
          at com.smartgwt.client.widgets.BaseWidget.error(BaseWidget.java:557)
          at com.smartgwt.client.widgets.BaseWidget.error(BaseWidget.java:545)
          at com.smartgwt.client.widgets.BaseWidget.setAttribute(BaseWidget.java:567)
          at com.smartgwt.client.widgets.BaseWidget.setID(BaseWidget.java:319)
          at smarttestcase.client.SmartTestCase.createNewTab(SmartTestCase.java:44)
          at smarttestcase.client.SmartTestCase.access$0(SmartTestCase.java:40)
          at smarttestcase.client.SmartTestCase$1.onClick(SmartTestCase.java:27)
          at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:96)
          at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1)
          at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
          at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
          at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:66)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:592)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
          at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
          at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
          at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:592)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
          at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
          at java.lang.Thread.run(Thread.java:595)
      Last edited by hin3x; 29 Sep 2010, 01:40.

      Comment


        #4
        This error would not result from the code you've shown. It would result only from calling setID() after you had already added a component to a drawn parent, or draw()n the component directly, which is incorrect usage.

        Comment


          #5
          Originally posted by Isomorphic
          This error would not result from the code you've shown. It would result only from calling setID() after you had already added a component to a drawn parent, or draw()n the component directly, which is incorrect usage.
          Indeed, if you click the 'Add tab'-button twice, you get the error shown in my first post.
          So what is the best (correct) approach for (dynamically) creating tabs with the same structure?

          Comment


            #6
            There is a flaw in your code, in that you are creating more than one Button with the same ID. That will also be reported as an error, but the error message is not the one you've posted.

            Comment


              #7
              Originally posted by Isomorphic
              There is a flaw in your code, in that you are creating more than one Button with the same ID. That will also be reported as an error, but the error message is not the one you've posted.
              So there's no way of dynamically creating tabs with the same structure/widgets (and same ids)? Because only one tab is shown at the same time, the other ones are hidden..
              e.g.:
              public Tab createUserManagerPanel(){
              ....
              panel.setID("userManager");
              ....
              }
              How can I open two tabs with the UserManagerPanel as content simultaneously?

              Comment


                #8
                By using IDs that are not static (eg, adding an ever-increasing count suffix "1", "2", etc).

                This is not a problem unique to SmartGWT, it is the standard problem of needing to come up with a strategy to provide deterministic IDs to asynchronously created components, and it occurs when testing any kind of software. Please think this problem through on your own, and if you have questions that are specific to how it applies to SmartGWT, go ahead and ask those.

                Comment

                Working...
                X