gpt4 book ai didi

jquery - Protractor - 获取菜单元素时出现问题

转载 作者:太空宇宙 更新时间:2023-11-04 09:11:45 25 4
gpt4 key购买 nike

我正在尝试获取不同的菜单项来测试链接,我已经想出了如何使用下拉菜单来执行此操作,但只是一个通用的导航栏给我带来了问题。这是我尝试使用的 Protractor 代码

// globals for second menu
var mainMenu = element.all(by.id('mainMenu'));

// Second menu
this.dashboard = function() {
mainMenu.get(0).element(by.linkText('Dashboard')).click();
browser.waitForAngular();
}

this.content = function() {
mainMenu.get(1).element(by.linkText('Content')).click();
browser.waitForAngular();
}


describe('Should Test main Navbar functions', function() {

it('Dashboard should direct to dashboard page', function() {
navbar.dashboard();
expect(browser.getCurrentUrl()).toContain(dashboardUrl);
});

it('Content should direct to course page', function() {
navbar.content();
expect(browser.getCurrentUrl()).toContain(contentUrl);
})
});

HTML 组件。

enter image description here

最佳答案

试试这个:

this.mainMenu = element(by.id('mainMenu'));
这个.mainMenu.click();
this.element(by.linkText('Dashboard')).click();

类似地,您可以使用其他菜单

this.mainMenu.click();
this.element(by.linkText('Content')).click();

关于jquery - Protractor - 获取菜单元素时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42078564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com