I've just started learning automation, and robot is my first framework, I'm solving some tests from letcode.in practice. But I can't solve two problems from the second test: 1) Get the background color of the button 2) Press and hold the button. I will be grateful for any help or comments.
*** Settings ***
Documentation First robot test
Library SeleniumLibrary
Library .venv/Lib/site-packages/robot/libraries/XML.py
*** Variables ***
${URL} https://letcode.in/buttons
${BROWSER} Chrome
${hold_button} css://#color
*** Keywords ***
Prepare for test
Open Browser ${URL} ${BROWSER}
Set Selenium Speed 3 seconds
*** Test Cases ***
Buttons
Prepare for test
Maximize Browser Window
Click Button id:home
Go Back
${y_coord}= Get Vertical Position id:position
${x_coord}= Get Horizontal Position id:position
Log Y coordinate: ${y_coord}
Log X coordinate: ${x_coord}
# ${color}= Get Element Attribute id:color style.background-color
# Log Button color:${color}
${tall&fat}= Get Element Size id:property
Log Button sizes: ${tall&fat}
Element Should Be Disabled id:isDisabled
# Click Button ${hold_button}
# Click Element ${hold_button}
# Sleep 3
I`ve commented my last attempts, I'm a beginner, so I'm not sure if I'm good at reading documentation and searching for information on the Internet.
this code is currently working for me:
*** Settings ***
Documentation First robot test
Library SeleniumLibrary
*** Variables ***
${URL} https://letcode.in/buttons
${BROWSER} Chrome
${HOLD_BUTTON} //button[contains(., 'Button')]
*** Test Cases ***
Buttons
[Documentation] Test case
Prepare For Test
Maximize Browser Window
Click Button id:home
Go Back
${y_coord}= Get Vertical Position id:position
${x_coord}= Get Horizontal Position id:position
Log Y coordinate: ${y_coord}
Log X coordinate: ${x_coord}
${color}= Get Element Attribute id:color style.background-color
Log Button color:${color}
${tall&fat}= Get Element Size id:property
Log Button sizes: ${tall&fat}
Element Should Be Disabled id:isDisabled
# Click Element ${HOLD_BUTTON}
Mouse Down ${HOLD_BUTTON}
Wait Until Page Contains Button has been long pressed timeout=5s
Mouse Up ${HOLD_BUTTON}
*** Keywords ***
Prepare For Test
Open Browser ${URL} ${BROWSER}
Set Selenium Speed 1 seconds