我无法获得Exact框架,也无法使用selenium web drive选择精确的元素

时间:2015-06-09 09:37:38

标签: javascript selenium-webdriver

    <script>
        document.cookie='_srn=;expires=Thu, 01 Jan 0000 00:00:00 GMT;';    
    </script>    
    <script>
        var strWindowId = "3pfb5VLw8QBMYH8eEuW2DFosHws0sm6e8da7mBeEXqsb";
    </script>
    <script language="javascript">
        navigator.id = "1433841867";</script>
    <script language="javascript">
        top._swescript = window;
    </script>
    <script language="javascript" src="23016/scripts/rtcEditor.js"></script>    
    <script language="javascript" src="23016/scripts/swecommon_top.js"></script>    
    <script language="javascript" src="23016/scripts/swecommon.js"></script>
    <script language="javascript" src="23016/scripts/navctrl.js"></script>
    <script language="javascript" src="23016/scripts/sweutil_keyboard.js"></script>
</head>

    <frameset rows="100%,*" border="0" frameborder="No" onunload="SWEUnloadApp(&quot;/esales_enu/start.swe&quot;,&quot;&quot;,&quot;3pfb5VLw8QBMYH8eEuW2DFosHws0sm6e8da7mBeEXqsb&quot;)">
        <frame name="_sweclient" title="" src="/esales_enu/start.swe?SWECmd=GetCachedFrame&amp;SWEACn=20956&amp;SWEC=1&amp;SWEFrame=top._sweclient&amp;SRN=3pfb5VLw8QBMYH8eEuW2DFosHws0sm6e8da7mBeEXqsb" marginheight="0" marginwidth="0" noresize="" scrolling="No" cd_frame_id_="295be8d5723232bd8677e4a4e252aa46">
        <frame name="_swe" title="" src="/esales_enu/start.swe?SWECmd=GetCachedFrame&amp;SWEACn=20956&amp;SWEC=1&amp;SWEFrame=top._swe&amp;SRN=3pfb5VLw8QBMYH8eEuW2DFosHws0sm6e8da7mBeEXqsb" marginheight="0" marginwidth="0" noresize="" scrolling="No" tabindex="-1">
    </frameset>
</html>

这实际上是我在HTML源代码中这是不可取的,因为.i想要点击下面的属性,但同样我没有进入上面的HTML源代码。当我手动检查元素时,我会得到以下属性但是当我运行我的脚本时相同。我没有找到元素异常并且没有找到框架异常

<input type="text" name="s_1_1_102_0" value="" style="width:132" id="s_1_1_102_0" tabindex="2997" maxlength="255">

如果我上面的评论不够,请帮我解决这个问题。请问我详细了解

2 个答案:

答案 0 :(得分:0)

当时元素可能没有加载。尝试对代码实施等待。很好的详细信息可以在这里找到 - http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp

答案 1 :(得分:0)

如果是同步问题,您可以尝试以下代码:

WebDriverWait wait = new WebDriverWait(driver, 50);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("iFrame")));