简体   繁体   中英

Selenium IDE get stuck in popup window javascript

I am brand new to selenium ide using fire fox. I am trying to test a calender which is a popup html and i read a lot of things and mostly said that I need to write "javascrtip select element ..." command but no matter how many times I tried I cant get it working . here is the site http://demo.owncloud.org/index.php/apps/calendar . when you click on the calender date there is a popup that comes in order for me to chose a date and hours and stuff. I dont know how you get the popup working in the selenium. I dont even know how you would understand if it is an ajax or javascript here is some part of the code that is about choosing calender

<div id="notification" style="display:none;"></div>
<div id="controls">
    <form id="view">
        <input type="button" value="Week" id="oneweekview_radio" original-title="">
        <input type="button" value="Month" id="onemonthview_radio" original-title="" class="active">
        <input type="button" value="List" id="listview_radio" original-title="">&nbsp;&nbsp;
        <img id="loading" src="/core/img/loading.gif" style="display: none;">
    </form>
    <form id="choosecalendar">
        <!--<input type="button" id="today_input" value="Today"/>-->
        <button class="settings generalsettings" title="Settings"><img class="svg" src="/core/img/actions/settings.svg" alt="Settings"></button>
    </form>
    <form id="datecontrol">
        <input type="button" value="&nbsp;&lt;&nbsp;" id="datecontrol_left" original-title="">
        <input type="button" value="April 2013" id="datecontrol_date" original-title="" class="hasDatepicker">
        <input type="button" value="&nbsp;&gt;&nbsp;" id="datecontrol_right" original-title="">
    </form>
</div>
<div id="fullcalendar" class="fc"><div class="fc-content" style="position: relative; min-height: 1px;"><div class="fc-view fc-view-month fc-grid" style="position: relative;" unselectable="on"><table class="fc-border-separate" style="width:100%" cellspacing="0"><thead><tr class="fc-first fc-last"><th class="fc-mon fc-widget-header fc-first" style="width: 182px;">Mon.</th><th class="fc-tue fc-widget-header" style="width: 182px;">

I would really appreciate any hint or help towards this.

Here is what I have

    <tr>
    <td>open</td>
    <td>/index.php/apps/files</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>//ul[@id='apps']/li[3]/a/img</td>
    <td></td>
</tr>

---------Popup shows here ----------
<tr>
    <td>click</td>
    <td>id=category</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=ui-id-6</td>
    <td></td>
</tr>
<tr>
    <td>select</td>
    <td>name=calendar</td>
    <td>label=test</td>
</tr>
<tr>
    <td>select</td>
    <td>name=accessclass</td>
    <td>label=Bizalmas</td>
</tr>
<tr>
    <td>click</td>
    <td>id=from</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>link=12</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=to</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>link=27</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=submitNewEvent</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>//body[@id='body-user']/div[9]/div/button</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=oneweekview_radio</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=oneweekview_radio</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=onemonthview_radio</td>
    <td></td>
</tr>

This is a calendar that you can interact with using Selenium IDE. Though you should also consider Selenium Webdriver using Selenium Grid which will allow you to test your code in multiple browsers. With that said lets get you interacting with this calendar pop-up!

I recommend using an element's id (when available) and when there is no id or the id is dynamic use xpath.

For an element that does not have an id such as the input element next to Title as pictured below use the following to click it's text box.

Command click

Target //input[contains(@placeholder, 'Title of the Event')]

在此处输入图片说明

Image of the Selenium IDE for the image above

在此处输入图片说明

TIP: Use the Find button to see if you have specified the element correctly with your xpath. It will get highlighted.

For most of the other elements you can use their id's

Command 'click' Target id=fromtime

The biggest TIP of all that I can add is use FIREBUG! If you are using Selenium IDE you Firebug will help you immensely. You are probably already using it, but just a tip for anyone that comes across this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM