差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
rf:rf:troubles:chrome:element_is_not_clickable [2018/01/28 18:19] tony |
rf:rf:troubles:chrome:element_is_not_clickable [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 3: | 行 3: | ||
===== Problem ===== | ===== Problem ===== | ||
這陣子將SeleniumLibrary升級至3.0之後,在Firefox上測試遇到難以解決的問題,也因此將測試瀏覽器改為Chrome;然而移到chrome之後,原先可以在firefox上執行的測試,反而變得無法執行。其中一樣就是出現Element is not clickable的問題。 | 這陣子將SeleniumLibrary升級至3.0之後,在Firefox上測試遇到難以解決的問題,也因此將測試瀏覽器改為Chrome;然而移到chrome之後,原先可以在firefox上執行的測試,反而變得無法執行。其中一樣就是出現Element is not clickable的問題。 | ||
- | ===== How to prevent the problem? ===== | + | ===== How to resolve? ===== |
- | + | 我要點擊的位置是Refresh的button:\\ | |
- | + | {{:rf:rf:troubles:chrome:rf_unclick_img.png|}}\\ | |
+ | 而我一開始使用的xpath是 | ||
+ | <code> | ||
+ | //span[text()='Refresh'] | ||
+ | </code> | ||
+ | {{:rf:rf:troubles:chrome:rf_unclick_problem_xpath.png|}}\\ | ||
+ | 但卻出現了以下錯誤訊息: | ||
+ | <code html> | ||
+ | WebDriverException: Message: unknown error: Element <span class="ui-button-text">...</span> is not clickable at point (805, 96). Other element would receive the click: <span class="ui-button-icon-primary ui-icon ui-icon-refresh"></span> | ||
+ | (Session info: chrome=63.0.3239.132) | ||
+ | (Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 6.3.9600 x86_64) | ||
+ | </code> | ||
+ | 後來從[[https://sites.google.com/a/chromium.org/chromedriver/help/clicking-issues|此篇文章]]得知,ChromeDriver使用模擬方式去點element中間的位置;假如你所給予的位置是使用者點不到的位置,就有可能會發生這樣的問題。\\ | ||
+ | \\ | ||
+ | 舉例來說,使用一個modal dialog會讓背景呈現蓋住的效果;對使用者來說,背景是無法點擊的。假如這時候透過ChromeDriver去點擊背景的element,就會發生無法點擊的問題。\\ | ||
+ | \\ | ||
+ | 以我的問題來說,將xpath改為圖片或button的xpath即可解決。\\ | ||
+ | \\ | ||
+ | 因此,Click Element的xpath最好是設定為使用者一定可以點擊的到的位置。 | ||
+ | ===== Reference ===== | ||
+ | * [[https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/2766|Chrome - Element is not clickable at point #2766]] | ||
+ | * [[https://sites.google.com/a/chromium.org/chromedriver/help/clicking-issues|Clicking issues of ChromeDriver]] | ||
+ | ===== ===== | ||
+ | ---- | ||
+ | \\ | ||
+ | ~~DISQUS~~ |