无法从HTML代码中检测到webelement

鲁皮什·辛德

我遇到了无法从源代码检测Web元素的情况。在我的代码中,您可以看到一个元素

<a class="CSPortalGuiListItemDrag" ondragstart="CSPortalGuiList.onDragStart(event, '', '', '');" onclick="return false;" href="#"> By Suite </a>

我正在尝试检测。

在此之前,我将简短地告诉您。为查找元素,我使用了Xpath,className和CSS。我尝试了绝对路径和相对路径,但没有一个起作用。

尝试A 1.切换到默认内容。2.切换到i-frame。3.切换到i框架3.查找元素。

尝试B 1.切换到默认内容。2.切换到i-frame 3.find元素。

尝试C 1.切换到i框架。2.查找元素。

所有尝试均未成功,无法检测到Web元素。

请给我您的宝贵建议。下面是源代码

<html>
<head>
<body>
<iframe scrolling="auto" frameborder="no" src="../admin?redirect=true&" marginwidth="0" marginheight="0">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="de-DE" dir="ltr" xml:lang="de-DE" xmlns="http://www.w3.org/1999/xhtml">
<head>
<body class="CSPortal Win ff17 ff SingleWidget SingleTab editmode" ffdragdropid="dd_1">
<div id="CSPortalPortalTitle" onclick="CS.reloadTopFrame();">Rupesh</div>
<div id="CSPortalPortalLogo" onclick="CS.reloadTopFrame();"></div>
<div id="header">
<div id="main" class="tabs1 t1 st0">
<div id="footer">
<div id="CSPortalWindow" class="CSPortalWindow" name="CSPortalWindow" style="width: 1000px; height: 568px; left: 20px; top: 20px; z-index: 10003;">
<div class="CSPortalWindowToolbar">
<div style="background-color: white; position: relative; overflow: auto; width: 1000px; font-size: 0px; height: 526px;">
<iframe frameborder="0" style="background-color: white; border: medium none; width: 100%; height: 100%; margin: 0px; padding: 0px;" src="../admin/portal.php?forward=core/extensions/portal/gui/framework/CSPortalGuiWidgetSelector.php&mode=add&PortalTabID=131&col=1">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html style="height:100%">
<head id="CSGuiWindowHead">
<body id="CSGuiWindowBody" class="Win ff17 ff hasHeight" oncontextmenu=";" style="background-color: #FFFFFF; height:100%;width: 100%;">
<div id="CSPortalLayoutManager_4367034" class="CSPortalGuiLayout">
<div class="CSPortalGuiLayoutInnerDiv">
<table class="CSPortalGuiLayout">
<tbody>
<tr>
<tr id="CSPortalLayoutManager_4367034_Middle">
<td id="CSPortalLayoutManager_4367034_Center" class="CSPortalGuiLayoutCenter" colspan="3">
<div class="CSPortalGuiLayoutCenterOverflow">
<div id="CSPortalLayoutManager_4367034_CenterContent" class="CSPortalGuiLayoutCenterOverflow2">
<table class="CSPortalGuiLayoutCenterTable" style="border-collapse: collapse; width: 100%; height: 100%;">
<tbody>
<tr>
<td id="Col1" class="CSPortalGuiLayoutCenterCol First Odd" width="200" height="0">
<div id="CSPortalLayoutManager_3849853" class="CSPortalGuiLayout">
<div class="CSPortalGuiLayoutInnerDiv">
<table class="CSPortalGuiLayout">
<tbody>
<tr>
<tr id="CSPortalLayoutManager_3849853_Middle">
<td id="CSPortalLayoutManager_3849853_Center" class="CSPortalGuiLayoutCenter" colspan="3">
<div class="CSPortalGuiLayoutCenterOverflow">
<div id="CSPortalLayoutManager_3849853_CenterContent" class="CSPortalGuiLayoutCenterOverflow2">
<div id="CSPortalGuiList_4885314" class="CSPortalGuiList unmarkable maxHeight list">
<style type="text/css">
<table class="CSPortalGuiListContainer">
<tbody>
<tr>
<td id="CSPortalGuiList_4885314_TdContent" class="CSPortalGuiListTdContent">
<div class="CSPortalGuiListOverflow">
<div id="CSPortalGuiListContentCSPortalGuiList" class="CSPortalGuiListContent">
<table class="CSPortalGuiListTable" name="CSPortalGuiList">
<tbody class="CSPortalGuiListBody">
<tr id="CSPortalGuiListItem_4885314_0" class="CSPortalGuiListItem first hasAction " clickhandler="1" onclick="var event=arguments[0]||window.event;var param=arguments[1];var tr=this;if (CSPortalGuiList && !CSPortalGuiList.clickItem(tr, event)) return false;tr.callback = function(event){ listCONTENTSERVModules(); };tr.callback(event);" style="" title="">
<td class="CSPortalGuiListItemContent">
<div class="CSPortalGuiListItemCaption">
<a class="CSPortalGuiListItemDrag" ondragstart="CSPortalGuiList.onDragStart(event, '', '', '');" onclick="return false;" href="#"> By Suite </a>
</div>
</td>
<td id="CSPortalGuiListActions_4885314_0" class="CSPortalGuiListItemAction">
</tr>
<tr id="CSPortalGuiListItem_4885314_1" class="CSPortalGuiListItem hasAction " clickhandler="1" onclick="var event=arguments[0]||window.event;var param=arguments[1];var tr=this;if (CSPortalGuiList && !CSPortalGuiList.clickItem(tr, event)) return false;tr.callback = function(event){ listCONTENTSERVVendors(); };tr.callback(event);" style="" title="">
<tr id="CSPortalGuiListItem_4885314_2" class="CSPortalGuiListItem hasAction " clickhandler="1" onclick="var event=arguments[0]||window.event;var param=arguments[1];var tr=this;if (CSPortalGuiList && !CSPortalGuiList.clickItem(tr, event)) return false;tr.callback = function(event){ listCONTENTSERVMostPopular(); };tr.callback(event);" style="" title="">
<tr id="CSPortalGuiListItem_4885314_3" class="CSPortalGuiListItem last hasAction " clickhandler="1" onclick="var event=arguments[0]||window.event;var param=arguments[1];var tr=this;if (CSPortalGuiList && !CSPortalGuiList.clickItem(tr, event)) return false;tr.callback = function(event){ listCONTENTSERVPreconfigured(); };tr.callback(event);" style="" title="">
</tbody>
</table>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
苏伯

尝试以下代码:-

 //switching to the frame using the frameelement that has your concerned webelement
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(@src,'CSPortalGuiWidgetSelector')]")));    

 //Locating the element inside the iframe after switching to it. 
 WebElement ele = driver.findElement(By.xpath("//a[class='CSPortalGuiListItemDrag']"));

 ele.click(); // in case you want to click the element

 driver.switchTo().defaultContent(); //to revert to the default window.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在功能中检测到无法访问的代码

从图像中检测到的 Aztec 代码无法快速工作

在C#控制器中检测到无法访问的代码

在此查询中无法检测到错误

无法从Kinect Feed中检测到脸部

无法检测到 UWP 中的按钮点击

Visual Studio代码(Windows)无法检测到全局NPM模块

使“检测到无法到达的代码”编译警告而不是TypeScript错误?

无法检测到自定义框架代码

Visual Studio代码无法检测到已安装的git

在for循环上检测到无法访问的代码

for循环-“检测到无法访问的代码”-测试

Ml Kit无法检测到护照MRZ代码?

“连接4”代码似乎无法检测到游戏片段

代码:虽然安装了块,但无法检测到gfortran

更改代码顺序后无法检测到Debug.Log

是什么导致无法检测到纯 JavaScript 中的 HTML 元素底部的滚动?

错误TS7027:在Angular2 TypeScript Service类中检测到无法访问的代码

代码点火器-无法在Google Maps V3 API中检测到我当前的纬度/经度位置

如何避免以下代码中检测到的竞争状况?

在托管代码中检测到空的[{}] json对象

在 cmd 和 vs 代码中未检测到 g++

在Ubuntu 14.04中,lsusb检测到了Gamepad,但PCSX或jstest-gtk无法检测到

Vim和NeoVim无法检测到Django HTML FileType

Flutter Doctor无法看到vs代码,VS代码无法检测到Flutter / bin

Onclick无法在Android中的列表行中检测到

CS0429-使用MSBuild 4检测到无法到达的表达式代码,但未检测到14

无法在android中检测到互联网

Spyder无法检测到导入的python文件中的更改