【发布时间】:2019-09-03 12:37:06
【问题描述】:
我正在尝试通过量角器单击隐藏在代码中的 div 类中的按钮。
我正在为我的工作开创一个量角器项目,并且已经到了我不再知道该怎么做的地步。我有一个隐藏在 div 类中的按钮,不允许我单击。我尝试使用 mouseMove 来获取按钮的坐标,我尝试使用特定按钮的 className 等。按钮没有 id。 id 不是问题,因为我尝试通过它的 id 单击另一个按钮,同样隐藏在 div 中。我需要知道如何通过 div 层才能单击按钮,因为其余的测试将依赖于它。
APPLICATION CODE:
::before
<dashboard-label>
<div class="att-topic-analysis-tabs">
<div class="att-button-group">
<button class="btn btn-default btn-lg att-close-topic ng-scope"
role="presentation" tabindex="-1"
ng-click="removeTopic(currentTopic.id)" translate>
Close Topic
</button>
</div>
</div>
PROTRACTOR TEST:
it('Closes Topic Successfully', function(){
//opens the first available topic
openTopic.click();
//checks that the URL contains 'topics' after 5 seconds
browser.wait(proExpect.urlContains('topics'), 5000);
var closeTopic = element(by.className('att-close-topic'));
//browser.wait(proExpect.elementToBeClickable(closeTopicButton), 5000);
console.log(closeTopic);
closeTopic.click();
browser.wait(proExpect.urlContains('home'), 5000);
});
如您所见,关闭主题按钮有点隐藏在 div 类中,标准点击不起作用。任何信息将不胜感激
【问题讨论】:
-
找到按钮了吗?即
closeTopic是否已定义并且点击不起作用? -
是的,点击不起作用
-
我有一个登录测试,它也点击了一个很好用的按钮!唯一不同的是它没有埋在div中
-
您是否有可能在元素可点击之前尝试点击它?量角器具有适合这种场合的功能。 protractortest.org/#/…
-
我会试试的
标签: angularjs selenium protractor