我正在尝试单击下拉菜单。但只有在headless状态下才会遇到ElementClickInterceptedException。当我检查屏幕截图时,遇到了错误,下拉菜单被点击,但没有被发现。这很奇怪
这是我使用无头的代码
Open Browser Window
[Arguments] ${LANGUAGE_CODE}
# NOTE: Chrome Options is needed for Jenkins to have the 1920 x 1080 size
Open Browser ${LOGIN URL} ${BROWSER} options=add_argument("--lang\=${LANGUAGE_CODE}");add_argument("--headless");add_argument("--window-size=1920,1080");
Maximize Browser Window
这是用来点击下拉菜单的代码
${visible} Run Keyword And Return Status Element Should Be Visible ${ppp_cmbGrid}
Run Keyword If ${visible}
... Click Element ${ppp_cmbGrid}
我在stackoverflow中看到了其他相同的问题,并且已经尝试了这些:
Open Browser Window
[Arguments] ${LANGUAGE_CODE}
# NOTE: Chrome Options is needed for Jenkins to have the 1920 x 1080 size
Open Browser ${LOGIN URL} ${BROWSER} options=add_argument("--lang\=${LANGUAGE_CODE}");add_argument("--window-size=1920,1080");add_argument("--start-maximized");add_argument("--headless")
并补充了这些:add_argument('--disable-blink-features=AutomationControlled')
但仍然得到这个错误
ElementClickInterceptedException: Message: element click intercepted: Element <div class="combobox custom" style="width: calc(100% - 1px); text-align: left;">...</div> is not clickable at point (951, 224). Other element would receive the click: <span class="dropdown-placeholder" style="height: 45px;">...</span>
(Session info: headless chrome=114.0.5735.198)
Stacktrace:
Backtrace:
GetHandleVerifier [0x00728893+48451]
(No symbol) [0x006BB8A1]
(No symbol) [0x005C5058]
(No symbol) [0x005F4BA4]
(No symbol) [0x005F36E8]
(No symbol) [0x005F1EEB]
(No symbol) [0x005F12FE]
(No symbol) [0x005E9AAC]
(No symbol) [0x0060A2BC]
(No symbol) [0x005E9586]
(No symbol) [0x0060A614]
(No symbol) [0x0061C482]
(No symbol) [0x0060A0B6]
(No symbol) [0x005E7E08]
(No symbol) [0x005E8F2D]
GetHandleVerifier [0x00988E3A+2540266]
GetHandleVerifier [0x009C8959+2801161]
GetHandleVerifier [0x009C295C+2776588]
GetHandleVerifier [0x007B2280+612144]
(No symbol) [0x006C4F6C]
(No symbol) [0x006C11D8]
(No symbol) [0x006C12BB]
(No symbol) [0x006B4857]
BaseThreadInitThunk [0x75EA7D59+25]
RtlInitializeExceptionChain [0x77CEB74B+107]
RtlClearBits [0x77CEB6CF+191]
2条答案
按热度按时间6xfqseft1#
ElementClickInterceptedException发生在网页上的一个元素由于另一个元素重叠或拦截点击动作而不可点击时。在无头模式下运行测试时经常会出现此问题,因为与在常规浏览器窗口中运行相比,布局和呈现可能会有所不同。
您可以尝试以下操作:
jaql4c8m2#
此错误消息...
...意味着你已经尝试在
<div>
元素上调用click:标识为**
${ppp_cmbGrid}
**。理想情况下,除非特殊情况,否则
<div>
元素是不可点击的。因此,点击被以下因素遮挡:解决方案
要单击下拉菜单,您需要调用
<span>
标记上的单击。