简体   繁体   English

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

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

I am trying to located elements that is in an html file that is included into my main app. 我正在尝试查找包含在我的主应用程序中的html文件中的元素。

When i try to use driver.findElement(by.className('name')) , it says element not found. 当我尝试使用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>

i am trying to click() the tag ''title=History'' , but webdriver says it cant find that element, am i doing it right? 我正在尝试单击()标签``title = History'',但是webdriver说它找不到该元素,我做对了吗?

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

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

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

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

相关问题 如何通过HTML循环获取元素? - how do I get elements by loop, html? 如何在Grails中呈现包含HTML中包含源文件的HTML文件? - How do i render a html file in grails that has source files included in the html? 使用 ajax 包含 HTML - 如何访问包含的文件元素? - HTML include using ajax - how to access the included files elements? 如何使用Selenium WebDriver和Autohotkey获取HTML中的元素总数? - How to get the total number of elements in a HTML with Selenium WebDriver and Autohotkey? 为什么当我检查循环中的字符串是否包含在字符串数组中时,所有字符串都为假? - Why when I check to see if a string in a loop is included in an array of strings do I get false for all of them? 如何获得HTML Canvas中旧生成的元素的引用? - How do I get reference of old generated elements in HTML Canvas? 如何将带引号的 HTML 元素放入 Bootstrap 弹出窗口? - How do I get HTML elements with quotation marks into a Bootstrap popover? 如何在javascript中获取特定HTML标记的所有元素? - How do I get all elements of a particular HTML tag in javascript? 如何单击Selenium Webdriver中的所有元素? - How Do I Click All Elements in Selenium Webdriver? 如何查看包含的 JavaScript 源代码? - How can I see included JavaScript sources?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM