Search code examples
dockerseleniumamazon-ec2ssl-certificaterobotframework

How to avoid SSLCertVerificationError when run Selenium Grid on AWS ec2 server


I build a Selenium Grid cloud server by docker on AWS ec2, and DNS point to CloudFlare.

I use Selenium Grid API to verify server status.

$ curl -X GET https://<my-host>/status

Service looks well

but I can't connect to server when I run robotframework

This is my code example.

Open Docker Browser
    [Arguments]    ${browserURL}    ${browserName}=${NONE}
    ${browserName} =    Evaluate    "${browserName}".capitalize()
    ${browserOptions} =    Evaluate    sys.modules['selenium.webdriver'].${browserName}Options()    sys, selenium.webdriver
    Call Method    ${browserOptions}    add_argument    --headless
    Call Method    ${browserOptions}    add_argument    --ignore-certificate-errors
    Call Method    ${browserOptions}    add_argument    --start-maximized
    Call Method    ${browserOptions}    add_argument    --allow-insecure-localhost
    ${options} =     Call Method     ${browserOptions}    to_capabilities
    Set To Dictionary    ${options}    browserName    ${DEFAULT_BROWSER}
    Set To Dictionary    ${options}    platform    ${DEFAULT_PLATFORM}
    ${executor} =    Evaluate    str("https://<my-host>")
    ${webdriver} =    Create Webdriver    Remote    alias=${browserName}    desired_capabilities=${options}    command_executor=${executor}
    Go to    ${browserURL}

This is error log

This seems to have some SSL error. I tried many ways but it still not work does somebody also got this issue? thanks.


Solution

  • I find the solution, I update my script. And update AWS settings from HTTPS to HTTP

    ${executor} =    Evaluate    str("example.com:80/wd/hub")
    

    It should work successfully.