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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With