Announcement

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

    Clarification regarding SmartClientWebDriver ScLocator idetification

    Hi,

    We are using SmartClientWebDriver for automation.

    Used version of SmartGWT
    smartgwtee-eval-5.0p
    Browser:Firefox/Chrome

    We have a Image, To identify that image we used sclocator and below is the locator given by selenium ID with firefox browser. (After adding user-extensions.js and user-extensions-ide.js files)

    scLocator=//TabSet[ID="page_MainWindowView_TabSet_mainScreenTabSet"]/paneContainer/member[Class=VLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=VLayout||index=0||length=2||classIndex=0||classLength=1]/member[Class=HLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=HLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=ImgButton||index=1||length=8||classIndex=1||classLength=7||roleIndex=1||roleLength=7||scRole=button||name=page_GroupTabLayout_gr_100100_ImgButton_discoverButton]/

    On clicking on that image, Image source change from "Search_Start.png" to "Search_Pause.png", and UI will now display different image.
    On this state if we look at sclocator (As mentioned below) is same as above one.

    scLocator=//TabSet[ID="page_MainWindowView_TabSet_mainScreenTabSet"]/paneContainer/member[Class=VLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=VLayout||index=0||length=2||classIndex=0||classLength=1]/member[Class=HLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=HLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=ImgButton||index=1||length=8||classIndex=1||classLength=7||roleIndex=1||roleLength=7||scRole=button||name=page_GroupTabLayout_gr_100100_ImgButton_discoverButton]/

    Here only way i can differentiate two state of the image buttor using src attribute under img tag.
    src complete path contains server IP (Ex:http://ServerIP:Port/Module1/images/common/tabIcons/24x24/Search_Start.png) but i can not use complete path since server IP and Port is keep changing.

    Same case in Xpath we have option of contains() function.So that we can check like as mentioned below
    Image1 : .//*[contains(@name,'gr_dummyGrpID_ImgButton_discoverButton') and contains(@src,'Search_Start')]
    Image2: .//*[contains(@name,'gr_dummyGrpID_ImgButton_discoverButton') and contains(@src,'Search_Pause')]

    How do we do it in sclocator to solve this case.?
    Is there option in sclocator that only partial string can be used instead of full ID,attribute value?

    Thanks

    #2
    We don't have that feature - and given that generated HTML for SmartGWT widgets may change cross browsers / over time, this kind of check (locating by src attribute) may not be the best solution for what you're trying to achieve.

    Let's take a step back - can you clarify what at a high level you're actually testing here?

    Presumably you have a SmartGWT widget on the page displaying a native img tag
    (Can you clarify -what kind of SGWT widget / how is the image displayed?)
    ...and as the user interacts with the application, it changes what src is being displayed
    -(how is the image updated? Via a built in behavior like rollover on a button / valueIcons on a formItem / change of state, etc or via application logic which simply calls 'setSrc()' on an Img type widget or similar)

    What do you actually need to test? We're assuming you need to verify what the img media actually is at some point to ensure your app is showing the expected UI for the current "state" of the application at some point.

    Once we have a clear picture of the scenario we should be able to describe the best way to achieve this.

    Comment


      #3
      Hi,
      Thank you for your response.

      >>Presumably you have a SmartGWT widget on the page displaying a native img tag (Can you clarify -what kind of SGWT widget / how is the image displayed?)

      We are using ImgButton discoverButton = new ImgButton();
      We are displaying using discoverButton.setSrc(hostURL+"images/Search_Start.png");

      >>(how is the image updated? Via a built in behavior like rollover on a button / valueIcons on a formItem / change of state, etc or via application logic which simply calls 'setSrc()' on an Img type widget or similar)

      We are using setSrc() for initial image display and on click we are again using setSrc() api, as shown below

      discoverButton.setSrc(hostURL+"images/Search_Pause.png");

      >>What do you actually need to test?
      We need to find currently displayed image and after clicking whether image is changed as expected. So we need to get WebElement for both the states of the image. But in both the state of the image, we are getting same scLocator (As we posted previously) so we could not achieve our requirement.

      We have attached same code and images.

      Please let us know, how do we achieve this.
      Thank you.
      Attached Files

      Comment


        #4
        For an immediate solution, we suggest using JavaScript to verify the value of ImgButton.src. You can wait for a JS expression to become true by calling SmartClientWebDriver.waitForCondition().

        Your JS should simply grab the ImgButton by its locator using the AutoTest.getObject() API, and then verify the src property. Using the locator you provided above (you'll need to scroll to see it all):
        Code:
        String jsVerifyImgButton = "var button = isc.AutoTest.getObject('scLocator=//TabSet[ID=\"page_MainWindowView_TabSet_mainScreenTabSet\"]/paneContainer/member[Class=VLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=VLayout||index=0||length=2||classIndex=0||classLength=1]/member[Class=HLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=HLayout||index=0||length=1||classIndex=0||classLength=1]/member[Class=ImgButton||index=1||length=8||classIndex=1||classLength=7||roleIndex=1||roleLength=7||scRole=button||name=page_GroupTabLayout_gr_100100_ImgButton_discoverButton]/'); button.src == 'foo.png'";
        
        boolean success = smartClientWebDriver.waitForCondition(jsVerifyImgButton);
        Future releases may improve how locators are generated or interpreted to avoid having to write such JavaScript.

        Comment

        Working...
        X