Announcement

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

    Selenium scLocator not working for context menu item

    Hi I'm trying to automate a context menu using scLocators generated by the the Selenium IDE FF addon.

    I'm able to generator scLocators that work for all DOM elements except menu items in a context menu.

    I'm using v11.1p_2018-02-09/PowerEdition Deployment (built 2018-02-09).

    For generating the selectors I'm using FF ESR 52.6.0 + Selenium IDE addon 2.9.1 + ISC selenium plugins: user-extensions.js + user-extensions-ide.js

    For my selenium testing I'm using Chrome version 64.0.3282.167.

    Typically the generated scLocators are the autoId kind and they all seem to work.
    The *working* scLocator for the root context menu is: //autoID[Class=VLayout||index=9||length=54||classIndex=0||classLength=35]/member[Class=HLayout||index=1||length=3||classIndex=0||classLength=1]/member[Class=VLayout||index=0||length=3||classIndex=0||classLength=1]/member[Class=TabSet||index=0||length=1||classIndex=0||classLength=1]/tabPane[title=Overview||ID=_PG_0||index=0]/member[Class=TabSet||index=1||length=2||classIndex=0||classLength=1]/tab[title=%3Cb%3E%3Cfont%20color%3D%22green%22%3E*Aggregate%20Loans%20-%20All%20Product%20Types%3C%24fs%24font%3E%3C%24fs%24b%3E||index=0]/" The context menu items all yield scLocators that look like this:
    //Menu[level=0]/body/row[title=Sandbox||6]/col[fieldName=title||1]"
    //Menu[level=1]/body/row[title=Switch%20workspace%20to%20new%20sandbox...||5]/col[fieldName=title||1]
    None of these context menu item scLocators starting with '//Menu' seem to work. I get the following error on my IntelliJ console:

    Element not found! //Menu[level=0]/body/row[title=Sandbox||6]/col[fieldName=title||1]

    Attached is a screenshot of the context menu in FF and the associated scLocator generated in the Selenium IDE. I'm trying to automate the items in the context menu visible in the screenshot.


    Click image for larger version

Name:	ISC_context_menu_issue.png
Views:	48
Size:	210.1 KB
ID:	251892

    Thanks,

    Ryan

    #2
    You've redacted the top of your Selenium script, but we don't see where you're executing the contextMenu command that opens the menu you're attempting to click on. Are there Selenium commands in the redacted portion that open the context menu? If not that would obviously explain why the element isn't found. We see some calls to contextMenu at the end of your Selenium script, after you've already tried to click on the contextMenu locators, which would seem to suggest they're out of order . Perhaps you can redact only the private data in the commands and not the whole commands themselves?

    A complete log at debug level from Selenium IDE would be more helpful. Based on the sample script you show, you should receive a "timeout" error before the "element not found" since you're waiting on each menu locator before you click on it with waitForElementClickable(). Having the complete log would help isolate where things are going wrong.

    What would really help is for you to try to reproduce the problem while targeting one of our online samples. In your case, it looks like you don't have IDs for the menus, so we'll have to modify the sample slightly. Point your Selenium IDE to our SC 11.1p context menu sample, and replace the default code with this:

    Code:
    var sizeMenu = isc.Menu.create({
        autoDraw:false,
        data:[
            {title:"Small", checkIf:"widget.width == 50",
             click:"widget.animateResize(50,50)"},
            {title:"Medium", checkIf:"widget.width == 100",
             click:"widget.animateResize(100,100)"},
            {title:"Large", checkIf:"widget.width == 200",
             click:"widget.animateResize(200,200)"}
        ],
        width:150
    });
    
    
    var moveMenu = isc.Menu.create({
        autoDraw:false,
        width:150,
        data:[
            {title:"Up", click:"widget.animateMove(widget.getLeft(),widget.getTop()-20)"},
            {title:"Right", click:"widget.animateMove(widget.getLeft()+20,widget.getTop())"},
            {title:"Down", click:"widget.animateMove(widget.getLeft(),widget.getTop()+20)"},
            {title:"Left", click:"widget.animateMove(widget.getLeft()-20,widget.getTop())"}
        ]
    });
    
    var mainMenu = isc.Menu.create({
        width:150,
        data:[
            {title:"Visible", checkIf:"widget.isVisible()",
             click:"widget.isVisible() ? widget.animateHide('fade') : widget.animateShow('fade')"
            },
            {isSeparator:true},
            {title:"Size", submenu:sizeMenu, enableIf:"widget.isVisible()"},
            {title:"Move", submenu:moveMenu, enableIf:"widget.isVisible()"},
            {isSeparator:true},
            {title:"Reset",
                click:"widget.animateRect(200,75,100,100);widget.animateShow('fade')",
                icon:"other/yinyang.gif",
                iconWidth:20,
                iconHeight:20
            }
        ]
    });
    
    isc.MenuButton.create({
        ID:"mainMenuButton",
        title:"Widget",
        width:150,
        menu:mainMenu
    });
    
    
    isc.Img.create({
        ID:"widget",
        left:200,
        top:75,
        width:100,
        height:100,
        src:"other/yinyang.gif",
        contextMenu: mainMenu
    });
    Do you still see the problem creating scripts from that sample? We see no problem using context menu locators with it. For example, the following Selenium script, presented as pseudocode, moves the yin-yang to the right by clicking an inner menu item:

    Code:
    waitForElementClickable("scLocator=//testRoot[]/child[Class=Img||index=1||length=2||classIndex=0||classLength=1||name=main]/")
    contextMenu            ("scLocator=//testRoot[]/child[Class=Img||index=1||length=2||classIndex=0||classLength=1||name=main]/")
    waitForElementClickable("scLocator=//Menu[level=0]/body/row[title=Move||3]/col[fieldName=icon||0]")
    click                  ("scLocator=//Menu[level=0]/body/row[title=Move||3]/col[fieldName=icon||0]")
    waitForElementClickable("scLocator=//Menu[level=1]/body/row[title=Right||1]/col[fieldName=title||1]")
    click                  ("scLocator=//Menu[level=1]/body/row[title=Right||1]/col[fieldName=title||1]")

    Comment

    Working...
    X