這陣子將SeleniumLibrary升級至3.0之後,在Firefox上測試遇到難以解決的問題,也因此將測試瀏覽器改為Chrome;然而移到chrome之後,原先可以在firefox上執行的測試,反而變得無法執行。其中一樣就是出現Element is not clickable的問題。
我要點擊的位置是Refresh的button:
而我一開始使用的xpath是
//span[text()='Refresh']
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)後來從此篇文章得知,ChromeDriver使用模擬方式去點element中間的位置;假如你所給予的位置是使用者點不到的位置,就有可能會發生這樣的問題。