【问题标题】:Selenium finds the frame, but does not select itSelenium 找到框架,但没有选择它
【发布时间】:2011-12-09 14:53:37
【问题描述】:

我一直在尝试使用 Selenium 选择框架,但失败了。 HTML 代码如下所示:

<html>
<frameset rows="100,*" framespacing="0" frameborder="no" border="0">
    <frame scrolling="no" title="Home" name="home_frame" src="http://localhost/home/home_frame.aspx?" marginheight="2" marginwidth="0">
    <html>
        <body id="bodyC" class="Context">
                <table >
                    <tbody>
                        <tr class="homeBottom">                                                             
                            <div class="Styledhome">
                                <table style="border-width: 0pt;">
                                        <tr>
                                            <td>
                                                <div class="Layout_Center">
                                                    <ul id="hrl01" class="Layout_Tabs" >
                                                        <li id="hr101_Home" class="Layout_ActiveTab">
                                                            <a target="_top" href="http://localhost/home/default.aspx" onclick= "if(pagePreviouslyClicked()){return false;};">Home</a>

我执行以下操作:

Selenium.SelectFrame("relative=top");
Selenium.SelectFrame("home_frame");
Selenium.Click("link=Home");

但它没有选择 home_frame。我还尝试使用 Selenium IDE 记录测试,我只看到 Selenium.SelectFrame("home_frame"); 我尝试删除 relative=top 部分,但它仍然没有选择框架 home_frame。当我输入if (Selenium.IsElementPresent("home_frame")) 时,它返回true。所以,它正在寻找 home_frame,但没有选择它。

如果我在这里做错了什么,以及是否有其他方法可以实现这一点,请建议我。谢谢!

【问题讨论】:

  • 选择框架后你想做什么? Selenium.SelectFrame("home_frame") 是否会触发异常/超时?
  • 当一个框架被选中时你期望发生什么?
  • 我更新了我的问题。我正在尝试单击“主页”选项卡。

标签: iframe selenium selenium-rc frame


【解决方案1】:

试试:

$selenium.click("//a[text()='Home']")

【讨论】:

    猜你喜欢
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 2022-06-20
    • 2021-07-09
    • 1970-01-01
    • 2016-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多