Cannot locate element using recursion after it found it as visible

ⅰ亾dé卋堺 提交于 2019-12-02 04:20:10

This is what i am doing with(LOL) I assume steps would be (find dropbox - click dropbox - select value).

var getValueElement = {
        getValueSelector: function (x) {
            return 'li[data-value="'+ x + '"]';
        }
}; 

module.exports = {
    //[.. other elements and commands..]
    sections: {
        setResults: {
            commands:[getValueElement],
            selector: 'div[class*="select-theme-result"', //* mean contains,sometime class is too long and unique,also because i am lazy.
            elements: {
                setHighlight:'li[class*="select-option-highlight"]',
                setSelected:'li[class*="select-option-selected"]', 
                //set18: 'li[data-value="18"]',
                //set36: 'li[data-value="36"]' 
                // i think getValueFunction is better,what if you have 100+ of set.

            }}}}

In your test

var myPage = browser.page.searchPageObject();
var mySection = searchPage.section.setResults;

// [finding and clicking the dropdown so it opens and displays the options]
mySection
     .click('@dropboxSelector')
     .waitForElementVisible('@setHighlight',5000,false,
          function(){
            var set18 = mySection.getValueElement(18);
            mySection.click(set18);
            });

Ps:in my case(i think your case also), dropbox or any small third-party js framework which is used many times in your web app, so better create a different PageObject for it,make pageObject/section is simple as possible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!