无法通过Selenium webdriver定位元素?

时间:2016-09-25 04:49:14

标签: selenium

页面源代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html dir="ltr" lang="en">
 </head><script>var _AdfWindowOpenError='A popup window blocker has been detected in your browser. Popup blockers interfere with the operation of this application. Please disable your popup blocker or allow popups from this site.';</script>
<script src="/dc4custmanager/adf/jsLibs/Common10_1_3_4_0.js">  </script><script language="javascript">document.onkeydown=_noReload;var _blockReload=1;function _fixDialogTitle(){window.document.title=window.frames[0].document.title};</script>
<frameset title="Content" rows="100%,*" onload="_fixDialogTitle(); _sizeWin(window.frames[0],0,30)" onunload="_checkUnload(event)">
  <frame title="Content" frameborder="0" noresize src="/dc4custmanager/faces/view/edi/editEdiInfo.jsp?_afPfm=1.2&loc=en" longdesc="#">
  <noframes>Your browser does not support frames. Frames support is required for this functionality</noframes>

我可以通过Firefox IDE找到元素。但我无法通过webdriver定位元素。我在这里使用chrome。请帮帮我找到元素?

1 个答案:

答案 0 :(得分:0)

从您的页面源代码中,清楚地知道您的元素应该在框架中。

在框架/ iframe中定位元素之前,首先切换到它的框架。

 driver.switchTo().frame()

更多详情: How to switch frames?