Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99014

How to build a keyword so I don't have to run login to all the features of a web in a test case of robot framework using seleniumlibrary?

$
0
0

I wanna test the features about the website in my final project in my Subject about Testing. I literally beginner in this field and confused how to create keyword in robot framework so I don't have to include the login part to all the features that I am going to test.

As you can see in my sample code that in every single feature that I am going to test I have to start from login part first. Actually, there are 10 features that I am going to test off.

What I need to implement is I don't have to always login to each feature which means it reduces the process so I can jump to the features that I am going to test. I mean I have login function that handle to all the features.

Forgive me if my question is about confusing at all. I provide these sample codes below to make you understand about my question

*** Settings ***

 Library    SeleniumLibrary

*** Test Cases ***

 LoginTest

Open Browser    *website-url*    chrome
Set Selenium Implicit Wait    5
Sleep    2
Click Element    //*[@id="headertop"]/div/div/div[2]/ul[1]/li[1]/a
Input Text    xpath=//*[@id="login_register_form"]/div[1]/form/div[1]/div[1]/input    username
Input Password    xpath=//*[@id="login_register_form"]/div[1]/form/div[1]/div[2]/input   password
Click Element    xpath=//*[@id="sidebar-wp-submit"] 
Sleep    3

Log    Task Completed   

ViewProfileTest

Open Browser    *website-url*    chrome
Set Selenium Implicit Wait    5
Sleep    2
Click Element    //*[@id="headertop"]/div/div/div[2]/ul[1]/li[1]/a
Input Text    xpath=//*[@id="login_register_form"]/div[1]/form/div[1]/div[1]/input    username
Input Password    xpath=//*[@id="login_register_form"]/div[1]/form/div[1]/div[2]/input   password
Click Element    xpath=//*[@id="sidebar-wp-submit"] 
Sleep    3
Click Element    //*[@id="headertop"]/div/div/div[2]/ul[1]/li[1]/a
Sleep    1
Click Element    //*[@id="sidebar-me"]/ul[1]/li[3]/a

ViewHistoryTest

Open Browser    *website-url    chrome
Set Selenium Implicit Wait    5
Sleep    2
Click Element    //*[@id="headertop"]/div/div/div[2]/ul[1]/li[1]/a
Input Text    xpath=//*[@id="login_register_form"]/div[1]/form/div[1]/div[1]/input    username
Input Password    xpath=//*[@id="login_register_form"]/div[1]/form/div[1]/div[2]/input   password    
Click Element    xpath=//*[@id="sidebar-wp-submit"] 
Sleep    3
Click Element    //*[@id="headertop"]/div/div/div[2]/ul[1]/li[1]/a
Sleep    1
Click Element    //*[@id="sidebar-me"]/ul[1]/li[3]/a
Sleep    1
Click Element    //*[@id="user-mycred-history"]

What I want to Achieve: Login Once that test all the features without login in every feature


Viewing all articles
Browse latest Browse all 99014

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>