繁体   English   中英

我如何让网络驱动程序查看包含的html文件中的元素

[英]How do i get webdriver to see elements in included html files

我正在尝试查找包含在我的主应用程序中的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说它找不到该元素,我做对了吗?

请尝试以下操作(如果语法符合javascript,请检查语法):

browser.driver.findElement(By.xpath("//div[@title='History']")).click();

尝试使用以下任何路径,它们均应起作用:通过cssSelector browser.driver.findElement(By.cssSelector(“ div.page-tab.selected> span.page-tab-text.ng-binding”))。click() ; 通过xpath browser.driver.findElement(By.xpath(“ // div [[包含(@href,'#/ landing / notifications')和@ title ='History']”))。click();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM