[Selenium] Element is not clickable,Other element would receive the click

先贴一下Robot Framework脚本:

*** Settings ***
# this is the only place where we have to hard-code a path;
# when config.py is loaded it will alter the path to include the resources folder.
Variables   ../resources/config.py
Library     PageObjectLibrary
Library    SeleniumLibrary    run_on_failure=Capture Page Screenshot    screenshot_root_directory=${CURDIR}\selenium-screenshot        
Suite Setup       SeleniumLibrary.Open Browser    ${CONFIG["Indexpage"]}    ${BROWSER1} 
Suite Teardown    SeleniumLibrary.Close All Browsers

*** Variables ***
${BROWSER}    chrome
${BROWSER1}    headlesschrome

*** Test Cases ***
车场首页
    [Setup]    Go To Page    ParkIndex
    [Tags]    P1
    check_page_element
    click_payment_text_and_back    # 点击缴费说明
    The Current Page Should Be    ParkIndex
    input_plateNo        # 输入车牌号:京111111,点击查费按钮,参数为是否开启引导绑车弹窗
    The Current Page Should Be    FeeDetails

公司采用的是 Page Object 设计模式来组织GUI层级的测试用例,其中../resources/config.py是自定义的变量文件,用来切换脚本运行环境, PageObjectLibrary是用来实现Page Object模式的一个库,用下来之后发现和项目需求有些不兼容,后续进行了一些修改;

调试脚本时,使用chrome都是通过的,然而实际在Jenkins slave上是采用headlesschrome来跑脚本,但是怎么跑都会报同样的错误:

20190110 18:50:15.205 : FAIL : WebDriverException: Message: unknown error: Element <button class="s_btn_lg font16" id="paybtn">...</button> is not clickable at point (400, 529). Other element would receive the click: <div class="cofco-footer_fixContent">...</div>
  (Session info: headless chrome=71.0.3578.98)
  (Driver info: chromedriver=71.0.3578.80 (2ac50e7249fbd55e6f517a28131605c9fb9fe897),platform=Windows NT 10.0.17134 x86_64)

后来发现headlesschrome进行实例化浏览器时默认是以全屏模式,而chrome则是以768*1024,这就导致我定位的元素被遮挡,无法定位,所以我对脚本进行了优化,只需要修改Suite Up为:

Suite Setup       BuiltIn.Run Keywords    SeleniumLibrary.Open Browser    ${CONFIG["Indexpage"]}    ${BROWSER1}    AND    SeleniumLibrary.Set Window Size    768    1024

这样再去执行脚本就不会报错了。。。。

猜你喜欢

转载自blog.csdn.net/weixin_33762321/article/details/87517468