Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct syntax to use with Click Button

I'm writing a robot framework/Selenium test script to validate the login process for a web site. I'm unable to get the correct syntax to automate the press of the Login button. Here is the robot script:

*** Settings ***
Documentation     Project Automated Test
Library           SeleniumLibrary

*** Variables ***
${LOGIN URL}      http://localhost/project
${BROWSER}        Chrome

*** Test Cases ***
Valid Login
    Open Browser To Login Page
    Maximize Browser Window
    Welcome Page Should Be Open
    Login_User
    [Teardown]    Close Browser

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}

Welcome Page Should Be Open
    Page should contain  Project Tasks

Login_User
    Click Button  Login

Here is the code for the Login button:

<input class="btn" type="button" onclick="
                if(document.getElementById('authentication').style.display == 'none'){
                    $('#authentication').slideDown('slow');
                                    } else {
                    $('#authentication').slideUp('slow');
                }
                " href="#" value="Login">

When the script starts Chrome opens up and the web page is displayed correctly. I can see the Login button on the web page. I've tried various combinations for the Click Button locator parameter (Login, value=Login, text=Login). Every attempt results in a Button with locator not found message. This is my first project with Robot Framework/Selenium so any help would be appreciated. Thanks!

like image 536
jmq Avatar asked Sep 05 '25 02:09

jmq


1 Answers

The Third parameter is your locator you can use id,name,xpath or css selector.since id and name is NOT available you can use xpath or css selector.

 Login_User
        Click Button  xpath://input[@class='btn'][@value='Login']

OR css Selector

Login_User
        Click Button  css:input.btn[value='Login']

You can refer following robot framework documentation.

like image 130
KunduK Avatar answered Sep 07 '25 23:09

KunduK