量角器| selenium没有点击html元素

时间:2017-12-25 13:21:52

标签: selenium protractor

请帮我解决这个问题。 执行此代码后没有看到上下文菜单。

file: Grid.js

export default class Grid{
    btnAddClick(){
        browser.wait(async()=>{
                await browser.executeScript('document.querySelector(".Grid--Head--leftButton-plus").click();');
                return EC.presenceOf(element(by.css('.item-invoice_form_add_simple_position a')))
                && EC.presenceOf(element(by.css('.contextmenus')));
            },
            browser.params.timeWaitSelEl,
            'Element "menu point Add position" too long in the DOM.');
    }
}

测试文件: test.js

it('test', ()=>{
    let grid = new Grid();
    grid.btnAddClick();
    expect(element(by.css('.contextmenus')).isDisplayed())
        .toBeTruthy('contextmenu');
    expect(element(by.css('.contextmenus')).isPresent())
        .toBeTruthy('cont');

});

html模板:

HTML <div class="contextmenus"><ul style="z-index: 1000000;"> <li class=" tab-elem item-invoice_form_add_rate_expense_type"><a cid="c855">Добавить</a></li> <li class=" tab-elem item-invoice_form_add_simple_position"><a cid="c857">Добавить позицию</a></li> </ul></div>

HTML <div class="Grid--Head--leftButton theme-color--before Grid--Head--leftButton-plus" style="width: 23px;"> <div class="Grid--Head--leftButton--helper theme-color"></div> <div class="Grid--Head--leftButton--helper theme-color"></div> <div class="Grid--Head--leftButton--helper theme-color"></div> </div>

0 个答案:

没有答案