开发者

Can't type with selenium into contenteditable div displayed in IE8

开发者 https://www.devze.com 2023-03-10 15:13 出处:网络
I encountered following problem while automating Sharepoint site using selenium 1 in IE8 browser. I can not type intotag (Sharepoint people picker field)

I encountered following problem while automating Sharepoint site using selenium 1 in IE8 browser. I can not type into tag (Sharepoint people picker field) Below is the html code :

 <td sizcache="10" sizset="0">    
       <div tabIndex="0"
                title="People Picker"
                class="ms-inputuserfield"
                id="ctl00_ctl00_pePeopleEditor_upLevelDiv"
                style="overflow-x: hidden; overflow-y: auto; background-color:window; width: 100%; height: 18px; color: windowtext;"
                contentEditable="true"
                onkeydown="return onKeyDownRw(this, 'ctl00_ctl00_pePeopleEditor',3, true, event);"
                onkeyup="return onKeyUpRw('ctl00_ctl00_pePeopleEditor');"
                onclick="onClickRw(true, true);"
                onblur="updateControlValue('ctl00_ctl00_pePeopleEditor')"
                ondragstart="canEvt(event);"
                oncopy="docopy();"
                onpaste="dopaste();"
                onfocusin="this._fFocus=1;saveOldEntities('ctl00_ctl00_pePeopleEditor_upLevelDiv')"
                onfocusout="this._fFocus=0;"
                name="upLevelDiv"
                AutoPostBack="0"
                onChange="updateControlValue('ctl00_ctl00_pePeopleEditor')"
       />

       <textarea
               name="ctl$ctl00$pePeopleEditor$downlevelTextBox"
               title="People Picker"
               class="ms-input" id="ctl00_ctl00_pePeopleEditor_downlevelTextBox"
               style="position: absolute; width: 100%; display: none; height:20px;"
               onkeydown="return onKeyDownRw(this, 'ctl00_ctl00_pePeopleEditor', 3,true, event);"
               onkeyup="onKeyUpRw('ctl00_ctl00_pePeopleEditor');"
               rows="1"
               cols="20"
               AutoPostBack="0"
    开发者_高级运维   />
</td>

I tried to put the text into that field using selenium functions as follows but none of them work out:

self.selenium.click(div_locator)
self.selenium.type_keys(div_locator, "string")
self.selenium.key_press(div_locator, "string")
self.selenium.key_press_native(65)
------------------------------------------------------------------------------------

self.selenium.fire_event(div_locator,"focus")
self.selenium.type_keys(div_locator, "string")
self.selenium.key_press(div_locator, "string")
self.selenium.key_press_native(65)
----------------------------------------------------------------------------------

self.selenium.click_at(div_locator,"") 
self.selenium.type_keys(div_locator, "string")
self.selenium.key_press(div_locator, "string")
self.selenium.key_press_native(65)
------------------------------------------------------------------------------------

self.selenium.click(textbox_locator)
self.selenium.type(textbox_locator, "string")
self.selenium.type_keys(textbox_locator, "string")
self.selenium.key_press(textbox_locator, "string")
self.selenium.key_press_native(65)
------------------------------------------------------------------------------------

self.selenium.fire_event(textbox_locator,"focus")
self.selenium.type(textbox_locator, "string")
self.selenium.type_keys(textbox_locator, "string")
self.selenium.key_press(textbox_locator, "string")
self.selenium.key_press_native(65
----------------------------------------------------------------------------------

self.selenium.set_cursor_position(textbox,-1)
self.selenium.key_press(textbox_locator,  "\\13")
self.selenium.key_press_native(10)
self.selenium.key_press_native(65)

Note also that there is no problem with this field on FF and IE6

Does anyone has an idea how to handle this Sharepoint people picker field ?

Alek


I didn't find resolution for my problem, however it seems that this is a limitation of selenium 1.

According to David Burns one way to overcome this problem is to use Selenium 2. Indeed I can type into this field on IE8 with Selenium 2. David also indicated way to overcome problem with tags where contenteditable is set to true:

I have started moving my Internet Explorer Selenium Tests to use the WebDriver API to test the Editor component of our site. This is one of the hardest areas to automate with Selenium 1 because its using contentEditable on a div. I managed to test this using the components JavaScript API to inject HTML and then manipulate it and then use the API to get the HTML out again and check that it is correct.

To sum up I can:

  • switch to Selenium 2 with Webdriver
  • use JavaScript API components to inject the original HTML
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号