运行selenium Rc脚本时找不到定位器?

时间:2012-12-28 07:09:50

标签: selenium-rc

以下是我的网页形式......

        <div class="padding">
            <span class="new-line forty-six-bottom smaller">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nec arcu id enim tincidunt vulputate. Sed et elementum nisi. Donec rhoncus feugiat pharetra. Donec sed augue id urna congue commodo et quis nulla. </span>
            <form id="detailsForm" action="/xyz/home/personaldetails" method="post">
             <span class="new-line fifteen-bottom">     
                <label for="title">
                    Title:
                </label>
                <em>*</em>
                <span class="field-and-error">

                <select id="title" name="title" class="required" style="width:234px;">
                    <option value="">Please select</option>
                    <option value="Mr" selected="selected">Mr</option><option value="Mrs">Mrs</option><option value="Miss">Miss</option><option value="Dr">Dr</option><option value="Ms">Ms</option><option value="Sir">Sir</option><option value="Prof">Prof</option><option value="Dame">Dame</option><option value="Lord">Lord</option><option value="Lady">Lady</option><option value="RH">RH</option><option value="Rev">Rev</option><option value="Sister">Sister</option><option value="Father">Father</option><option value="Other">Other</option>

                </select>

                </span>
            </span>
            <span class="new-line fifteen-bottom">  
                <label for="firstName">
                    First name:
                </label>
                <em>*</em>
                <span class="field-and-error">

                <input id="firstName" name="firstName" type="text" value="Sivaji" maxlength="50"/>

                </span>
            </span>
            <span class="new-line fifteen-bottom">      
                <label for="lastName">
                    Last name:
                </label>
                <em>*</em>
                <span class="field-and-error">

                <input id="lastName" name="lastName" type="text" value="Ganesan" maxlength="50"/>

                </span>
            </span>
When I copy the xpath from the above HTML, i am getting //*[@id="firstName"].

我正在尝试使用

selenium.type("//input[@id='firstName']", "Chandra");

selenium.type("//*[@id='firstName']", "Chandra");

我正在

`12:28:37.854 INFO - Got result: ERROR: Element //input[@id='firstName'] not found on 

session 96a10231817c40e5aa370660fd05ba45`

任何人都可以澄清为什么它没有识别?同样的,如果我在IDE中录制,我能够实现,但在RC中我不能。

由于 钱德拉

1 个答案:

答案 0 :(得分:0)

下面的代码与给定的html代码段完全正常。

selenium.type("//*[@id='firstName']", "SantoshSarma");