Seleniumの動作(入力時例外/5:IE)
Internet Explorer
![11.973.17763.0](https://selenium-world.net/wp-content/uploads/2020/07/ie_version.png)
click()メソッドの動作
Seleniumのclick()メソッドは、IEでは、画面にフォーカスが当たっていないと正常に動作しません。
フォーカスの当たっていない状態では、1回目のクリックでコントロールにフォーカスが当たり、2回目のクリックでクリックイベントが発生します。
1回目のクリックでコントロールにフォーカスが当たります。
![フォーカス取得](https://selenium-world.net/wp-content/uploads/2020/07/ie_submit1_c1-1024x616.png)
2回目のクリックでクリックイベントが発生します。
![クリックイベント発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_submit1_c2-1024x616.png)
ブラウザのズーム倍率
IEメニューの「設定」から「拡大(Z)」を選んで、画面の倍率を90%にします。
![拡大率の設定](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_setting.png)
Button
submitボタン
「click」ボタンを何回押しても、クリックできません。フォーカスも取得できません。
![反応なし](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_submit_c1-1024x616.png)
is_enabled()は「Ture(有効)」です。
![is_displayed()=True](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_submit_c2-1024x616.png)
Link
クリックできません。
![反応なし](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_normal_link_c1-1024x616.png)
Text
文字入力可能です。
![文字入力](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_textbox_c1-1024x616.png)
Select
選択できます。
![option2選択](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_select_c1-1024x616.png)
Radio / CheckBox
クリックできません。
![反応なし](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_radio3_c1-1024x616.png)
ラベルをクリックしても、フォーカス取得、クリックイベントは発生しません。
![反応なし](https://selenium-world.net/wp-content/uploads/2020/07/ie_zm_radio3_c2-1024x616.png)
実行結果
コントロール | 要素 | 操作 | 結果 |
---|---|---|---|
Button | submit | click | NG |
button | click | NG | |
image | click | NG | |
Link | normal | click | NG |
img | click | NG | |
css | click | NG | |
Text | textbox | send_key | OK |
password | send_key | OK | |
textarea | send_key | OK | |
Select | select | select | OK |
Radio | radio | click | NG |
label | click | NG | |
CheckBox | checkbox | click | NG |
label | click | NG |
非表示要素
プルダウンメニューがクリックできるかを確認します。
![プルダウンメニュー](https://selenium-world.net/wp-content/uploads/2020/07/ie_menu3_c1.png)
Menu
「Menu3」の「child2」をクリックします。
例外が発生します。
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_menu3_c2-1024x616.png)
ElementNotInteractableExceptionMessage: Element is not displayed
<traceback object at 0x0000012DBE081648>
“is_displayed()"は「False(非表示)」です。
![is_displayed()=False](https://selenium-world.net/wp-content/uploads/2020/07/ie_menu3_c3-1024x616.png)
要素の上に、別の要素が重なっている
Alertダイアログ
「Menu1」をクリックすると、JavaScriptのAlertダイアログが表示されます。
Alertはモーダルダイアログです。
![alertダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_alert1-1024x616.png)
Windows10では、IEのAlertダイアログは2種類あり、何回か表示すると、チェックボックス付きに変わります。
再表示を抑制する文言「このページにこれ以上メッセージの作成を許可しない」及び、チェックボックスが表示されます。
![alertダイアログ(チェックボックス付)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_alert2-1024x616.png)
Button
通常のAlertダイアログと、チェックボックス付きのAlertダイアログで動作が異なります。
通常ダイアログ
Alertダイアログが表示された状態で、submitボタンをクリックすると、ダイアログが閉じて例外が発生します。
![通常ダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c1-1024x616.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c2-1024x616.png)
UnexpectedAlertPresentExceptionAlert Text: Menu1!
Message: Modal dialog present with text: Menu1!
<traceback object at 0x0000012DBE0AE848>
通常ダイアログでは、Chorme、Firefox、Edgeと同じく、要素の取得もできません。
チェックボックス付きダイアログ
Alertダイアログが表示された状態で、submitボタンをクリックすると、ダイアログが閉じてクリックイベントが発生します。
![チェックボックス付きダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c3-1024x616.png)
![クリックイベント発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c4-1024x616.png)
この場合は、要素がダイアログで隠れていてもクリック可能です。
![チェックボックス付きダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c6-1024x616.png)
![クリックイベント発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c7-1024x616.png)
なお、手動ではクリック不可です。
![クリック不可](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_sumit_c5-1024x616.png)
Link
Buttonと同様に、通常ダイアログとチェックボックス付きダイアログで動作が異なります。
通常ダイアログ
例外が発生します。
![通常ダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_normal_link_c1-1024x616.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_normal_link_c2-1024x616.png)
チェックボックス付きダイアログ
クリック可能です。
![チェックボックス付きダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_normal_link_c3-1024x616.png)
![クリックイベント発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_normal_link_c4-1024x616.png)
Text
通常ダイアログ
例外が発生します。
![通常ダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_textbox_c1-1024x616.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_textbox_c2-1024x616.png)
チェックボックス付きダイアログ
ダイアログが閉じ、文字が入力されます。
![チェックボックス付きダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_textbox_c3-1024x616.png)
![文字入力](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_textbox_c4-1024x616.png)
Select
通常ダイアログ
Alertダイアログが閉じ、例外が発生します。
![通常ダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_select_c1-1024x616.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_select_c2-1024x616.png)
チェックボックス付きダイアログ
ダイアログが閉じ、選択可能です。
![チェックボックス付きダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_select_c3-1024x616.png)
![option2選択](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_select_c4-1024x616.png)
Radio / CheckBox
通常ダイアログ
Alertダイアログが閉じ、例外が発生します。
![通常ダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_radio_3_c1-1024x616.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_radio_3_c2-1024x616.png)
チェックボックス付きダイアログ
ダイアログが閉じ、選択可能です。
![チェックボックス付きダイアログ表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_radio_3_c3-1024x616.png)
![Radio_3選択](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_al_radio_3_c4-1024x616.png)
実行結果
Alertダイアログ(通常)
![alertダイアログ(通常)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_alert3.png)
ダイアログが閉じ、例外が発生します。
コントロール | 要素 | 操作 | 結果 |
---|---|---|---|
Button | submit | click | Ex |
button | click | Ex | |
image | click | Ex | |
Link | normal | click | Ex |
img | click | Ex | |
css | click | Ex | |
Text | textbox | send_key | Ex |
password | send_key | Ex | |
textarea | send_key | Ex | |
Select | select | select | Ex |
Radio | radio | click | Ex |
label | click | Ex | |
CheckBox | checkbox | click | Ex |
label | click | Ex |
要素の取得もエラーになる。
SeleniumではAlertダイアログが閉じるが、手動では閉じない
Alertダイアログ(Window10:チェックボックス付き)
![alertダイアログ(チェックボックス付)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_alert4.png)
ダイアログが閉じ、入力可能です。
コントロール | 要素 | 操作 | 結果 |
---|---|---|---|
Button | submit | click | OK |
button | click | OK | |
image | click | OK | |
Link | normal | click | OK |
img | click | OK | |
css | click | OK | |
Text | textbox | send_key | OK |
password | send_key | OK | |
textarea | send_key | OK | |
Select | select | select | OK |
Radio | radio | click | OK |
label | click | OK | |
CheckBox | checkbox | click | OK |
label | click | OK |
Windows10のチェックボックス付きAlertダイアログ
- 通常ダイアログとチェックボックス付きとで、なぜ結果が異なるのか?
- 下記にある通り、confirm/promptではチェックボックスの有無による差異はありません。alertのみ動作が異なります。
- 同じチェックボックス付きでも、Firefoxでは動作に違いがないこと
- IEのWebDriverは32bitを使用しているが関係はあるのか?
- 32bit版のWindows10でも動きは変わらないのか?
疑問は色々とありますが、回避策を考える方が早いので、調査はここまでにします。
Windows10で表示されるようになった、「このページにこれ以上メッセージの作成を許可しない」という、再表示抑制のためのチェックボックスは評判が良くありません。
ダイアログに対する操作がオペレーションに必要な場合、一度チェックボックスにチェックを入れてしまうと、ダイアログが表示されなくなり、その後のオペレーションができなくなるという問題があります。
そのような場合は、自作するか、jQueryなどのライブラリを使用することをお勧めします。
confirm / promptダイアログ
Javascriptでは、alertの他に、confirmダイアログとpromptダイアログがあり、ともにモーダルです。
Windows10では、それぞれ2回目以降からの表示はチェックボックスが表示されますが、Alertと異なり、動作に違いはありませんでした。
confirmダイアログ
どちらも例外が発生
通常
![confirmダイアログ(通常)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_confirm_c1-1024x690.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_confirm_c2-1024x690.png)
チェックボックス付き
![confirmダイアログ(チェック付)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_confirm_c3-1024x690.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_confirm_c4-1024x690.png)
promptダイアログ
どちらも例外が発生
通常
![promptダイアログ(通常)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_prompt_c1-1024x690.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_prompt_c2-1024x690.png)
チェックボックス付き
![promptダイアログ(チェック付)](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_prompt_c3-1024x690.png)
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_prompt_c4-1024x690.png)
ダイアログ表示(モードレス)
「Menu2」をクリックすると、jQueryのモードレスダイアログが表示されます。
![dialog表示](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dialog1-1024x616.png)
Button
submitボタン
ダイアログが重なっている状態で、submitボタンをクリックします。
例外が発生します。
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_submit_c1-1024x616.png)
ElementClickInterceptedExceptionMessage: Element not clickable at point (832,367). Other element would receive the click: <p>This dialog is specfied "z-index:999".<br>
<traceback object at 0x000002470A8BBD48>
ダイアログを移動させて、submitボタンを表示すれば、クリック可能です。ただしIEの場合は、1回目でフォーカスを取得し、2回目のクリックでクリックイベントが発生します。
![クリックイベント発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_submit_c2-1024x616.png)
手動の場合もクリック可能です。
![クリックイベント発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_submit_c3-1024x616.png)
is_displayed()は「True(表示)」です。
![is_displayed()=True](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_submit_c4-1024x616.png)
Link
Buttonと同じく、要素が隠れていると例外が発生します。
Text
クリックと異なり、要素が隠れている場合でも、文字入力は可能です。
![文字入力](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_textbox_c1-1024x616.png)
![hoge](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_textbox_c2-1024x616.png)
Select
要素が隠れていても、選択可能です。
![option2選択](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_select_c1-1024x616.png)
![option2](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_dl_select_c2-1024x616.png)
Radio / CheckBox
ButtonやLinkと同じく、要素が隠れているとクリックできません。
実行結果
コントロール | 要素 | 操作 | 結果 |
---|---|---|---|
Button | submit | click | Ex |
button | click | Ex | |
image | click | Ex | |
Link | normal | click | Ex |
img | click | Ex | |
css | click | Ex | |
Text | textbox | send_key | OK |
password | send_key | OK | |
textarea | send_key | OK | |
select | select | OK | |
radio | radio | click | Ex |
label | click | Ex | |
checkbox | checkbox | click | Ex |
label | click | Ex |
例外が起きるのは、ダイアログで要素が隠れている場合
ヘッダー/フッター
スクロール追従型のヘッダー/フッターで要素が隠れている場合を考えます。
Button
submitボタン
submitボタンをヘッダーに隠した状態でclickボタンを押します。
例外が発生しました。
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_submit_c1-1024x616.png)
ElementClickInterceptedExceptionMessage: Element not clickable at point (832,86). Other element would receive the click: <a id="menu2" onclick="show_dialog()" href="#nav_sample">Menu2</a>
<traceback object at 0x0000027BE1149048>
is_displayed() は「True」です。
![is_displayed()=True](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_submit_c2-1024x616.png)
Link
Linkをヘッダーに隠した状態でclickボタンを押します。
例外が発生しました。
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_normal_link_c1-1024x616.png)
Text
textbox
textboxをヘッダーに隠した状態で、「send_key」ボタンを押します。
「hoge」と入力されます。
![文字入力](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_textbox_c1-1024x616.png)
![hoge](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_textbox_c2-1024x616.png)
Select
選択可能です。
![option2選択](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_select_c1-1024x616.png)
![option2](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_select_c2-1024x616.png)
Radio / CheckBox
Radioボタンをフッターに隠して、「click」ボタンを押します。
例外が発生します。
![例外発生](https://selenium-world.net/wp-content/uploads/2020/07/ie_hide_hd_radio3_c1-1024x616.png)
実行結果
コントロール | 要素 | 操作 | 結果 |
---|---|---|---|
Button | submit | click | Ex |
button | click | Ex | |
image | click | Ex | |
Link | normal | click | Ex |
img | click | Ex | |
css | click | Ex | |
Text | textbox | send_key | OK |
password | send_key | OK | |
textarea | send_key | OK | |
Select | select | select | OK |
Radio | radio | click | Ex |
label | click | Ex | |
CheckBox | checkbox | click | Ex |
label | click | Ex |
ディスカッション
コメント一覧
まだ、コメントがありません