Search code examples
seleniumrobotframework

Robotframework accept website's term of service


I wish to automate my www.tori.fi browsing using robotframework. My biggest problem thus far is to get the robot to click on the "Hyväksy kaikki evästeet"- button. Simple Xpath targetting won't do, as it does not find the element. The popup is obsctructicating the website.

I tried this:

Click Element    //*[@id="notice"]/div[6]/button[2]

But the result was:

Element with locator '//*[@id="notice"]/div[6]/button[2]' not found

Image of the websites TOS

I am on Firefox browser.


Solution

  • When we find an overlay, we should suspect of it being inside a frame. This is the case in the site under testing.

    Here is a complete working test suite:

    *** Settings ***
    Library           SeleniumLibrary
    
    *** Test Cases ***
    Click button in frame
        Open Browser    https://www.tori.fi/    firefox
        Sleep    5 seconds
        Select Frame    //iframe[@title="SP Consent Message"]
        ${button}=    Get WebElement    //button[@title="Hyväksy kaikki evästeet"]
        Click Element    ${button}
        Unselect Frame
        Sleep    5 seconds
        Capture Page Screenshot
        Close All Browsers