我正在尝试找到包含在我的主应用程序中的html文件中的元素。
当我尝试使用driver.findElement(by.className('name'))时,它表示找不到元素。
<div>
<!-- ngInclude: 'scripts/pageTabs/pageTabs.html' --><div ng-include="'scripts/pageTabs/pageTabs.html'" class="ng-scope"><div ng-controller="callCtrl" class="ng-scope">
<div class="page-tabs">
<div title="Directory" id="dirTab" ui-sref="landing.directory" class="page-tab" ng-class="{selected: $state.includes('landing.directory')}" href="#/landing/directory">
<span class="page-tab-icon icon-directory"></span>
<span class="page-tab-text ng-binding">Directory</span>
</div>
<div title="Conversations" id="actCommTab" ui-sref="landing.activity" class="page-tab" ng-class="{selected: $state.includes('landing.activity')}" href="#/landing/activity">
<span class="page-tab-icon icon-conversations"></span>
<div class="activeCount ng-binding">(0)</div>
<span class="page-tab-text ng-binding">Conversations</span>
</div>
<div title="History" ui-sref="landing.notifications" class="page-tab selected" ng-class="{selected: $state.includes('landing.notifications')}" href="#/landing/notifications">
<span class="page-tab-icon icon-history"></span>
<span class="page-tab-text ng-binding">History</span>
</div>
</div>
我想点击()标签''title = History'',但是webdriver说它找不到那个元素,我做得对吗?
答案 0 :(得分:0)
尝试以下方法(检查语法是否符合javascript):
browser.driver.findElement(By.xpath("//div[@title='History']")).click();
答案 1 :(得分:0)
尝试使用以下任何一种路径,它们应该有效: 通过cssSelector browser.driver.findElement(By.cssSelector(&#34; div.page-tab.selected&GT; span.page-制表text.ng结合&#34))。单击(); 通过xpath browser.driver.findElement(By.xpath(&#34; // div [[contains(@href,&#39;#/ landing / notifications&#39;)和@title =&#39; History&#39;] &#34))点击();