我使用Selenium Webdriver在Java中编码。我无法在页面中找到LINK Text“License Manager”。当我尝试切换到名为"text"
的帧时。 Selenium无法找到名为“text”的框架,请帮助。
这是我的代码:
d.switchTo().frame("enterpriseStatus");
d.findElement(By.id("bannerSettingsButton")).click();//settings button
d.manage().timeouts().pageLoadTimeout(15000, TimeUnit.SECONDS);
d.switchTo().window("name=text");//This is where something goes wrong
d.findElement(By.linkText("License Manager")).click();
这是框架来源:
<body>
<div class="tablecontentarea-div" style="width: 90%;">
<table class="tabletitlebar">
<tr>
<td>
<span class="titlepage">Settings</span>
</td>
</tr>
</table>
<div class="tablecontentpanel" style="padding-top: 15px;">
<table style="width:100%" summary="">
<tr>
<td style="width:50%; padding-right:7px; vertical-align: top;">
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/servers_32x32.png"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Device Management</div>
<div>
Add, manage, configure and delete devices.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/GettingStarted.do?actionName=main">Getting Started</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/DeviceListServlet">All Devices</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ArrayAssignment.do?actionName=listAssignments">Manage Agent Assignments</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/PolicyServlet?state=listPolicies">Policies</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/DeviceGroupList.do?actionName=showMainPage">Device Groups</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/FilersAssignment.do?actionName=viewNetAppFilerAssignment&filerAgentTypeID=401">NetApp Operations Manager</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ClusterAssignment.do?actionName=listAssignments">Virtualization (Assign ESX Hosts)</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=Arrays">Server Setup: Arrays</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=Database">Server Setup: Databases</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/alerting_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Rules & Alerting</div>
<div>
Setup rules that can perform a variety of actions, including running scripts.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules">All Rules</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules&ruleTypeId=3">Threshold Rules</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules&ruleTypeId=2">Windows Event Log Rules</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules&ruleTypeId=6">Asset Change Rules</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules&ruleTypeId=5">Scheduled Rules</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=Real Time">Server Setup: Real Time</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ScriptList.do?actionName=showMainPage">Scripts</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/file_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Files</div>
<div>
Configure file analysis, file rules, assign shares to agents.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules&ruleTypeId=1">File Analysis Rules</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/RulesList.do?actionName=listRules&ruleTypeId=4">Directory Analysis Rules</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/FileTypeGroupsList.do?actionName=showMainPage">File Type Groups</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/NasSharesAssignment.do">Assign Remote Shares</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/LocalSharesAssignment.do">Assign Local Shares</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=File Analysis">Server Setup: File Analysis</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/VmSharesAssignment.do">Discover VM Targets</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/FARepServlet">File Repository</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/user_accounts_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Users</div>
<div>
Add, edit, and remove user accounts.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/UserList.do?actionName=showMainPage">Manage Users</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=User Authentication">Server Setup: User Authentication</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td style="width:50%; padding-left:8px; vertical-align: top;">
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/server_profiler_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Storage Manager Server</div>
<div>
Configure and view information about your server.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do">Server Setup: All</a></td>
</tr>
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/AboutDisplay.do?actionName=displayLicense">About</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=E-mail">Server Setup: E-mail</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/DataRetentionPolicies.do">Data Retention</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/web_update_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">Updates & Upgrades</div>
<div>
Upload new modules and upgrade your agents and pollers.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ModuleList.do?actionName=showMainPage">Upload Modules</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ModulePush.do">Upgrade Agents</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/reports_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">GUI & Reporter</div>
<div>
Configure GUI and Reporting behavior.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=Reporter">Server Setup: Reporter</a></td>
</tr>
</table>
</td>
<td class="link-col-center">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/ServerSetup.do?sectionName=GUI">Server Setup: GUI</a></td>
</tr>
</table>
</td>
<td class="link-col-right">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/license_36x36.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">License Summary</div>
<div>
View your license type and number of storage modifiers.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="/LicenseManager.do?actionName=showLicenseManager">License Manager</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="setting-section">
<tr>
<td class="img-col">
<img src="/images/Icon.Thwack.gif"/>
</td>
<td class="desc-col">
<div class="titlesubwhitebg">thwack Community</div>
<div>
Import shared application templates posted on thwack, a community site for Solarwinds users. thwack features helpful devices, tips and downloads from over 20,000 network engineers.
</div>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<tr>
<td class="link-col-left">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top">» </td>
<td valign="top"><a href="http://thwack.com/forums/63/profiler/185/storage/" target="_blank">Storage thwack Forum</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</body>
答案 0 :(得分:1)
要切换到窗口,您必须使用WindowsHandle。
您可以尝试使用以下功能,前提是您正在处理具有不同标题的窗口。
private String mainWindowsHandle; // Stores current window handle
public static boolean swithToWindow(WebDriver driver,String title){
mainWindowsHandle = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles(); // Gets all the available windows
for(String handle : handles)
{
driver.switchTo().window(handle); // switching back to each window in loop
if(driver.getTitle().equals(title)) // Compare title and if title matches stop loop and return true
return true; // We switched to window, so stop the loop and come out of funcation with positive response
}
driver.switchTo().window(mainWindowsHandle); // Switch back to original window handle
return false; // Return false as failed to find window with given title.
}