*** Settings ***
Library SeleniumLibrary
Resource ../Tests/Main.robot
Resource SSmthn.robot
Library Dialogs
Library Collections
*** Variables ***
*** Keywords ***
Select Browser: User Input
${value} = get selection from user Select Browser Begin Web Test with Chrome Browser Begin Web Test with headlessChrome
${value}
Begin Web Test with Chrome Browser
${options}= Evaluate sys.modules['selenium.webdriver.chrome.options'].Options() sys
Call Method ${options} add_argument --disable-notifications
${driver}= Create Webdriver Chrome options=${options}
go to ${URL}
maximize browser window
sleep 2sec
Begin Web Test with headlessChrome
open browser ${URL} ${Browser}
maximize browser window
sleep 2sec
End Web Test
close all browsers
Here Iam asking user for one of the 2 selections.
${value}: stores value from user selection but does not call the keyword selected by the user. What can I change here to make it work?
A keyword which name is stored in a variable can be executed by using the Run Keyword keyword from the BuiltIn library.
Select Browser: User Input
${value} = get selection from user Select Browser Begin Web Test with Chrome Browser Begin Web Test with headlessChrome
Run Keyword ${value}
I'm learning Robot Framework and I want to run a Excel file for my data of the test case.
When I run the code, The report shows all test case names are the same.
In my Excel file, the first column is "* Test Cases *". I want the name of test case will be chosen from there.
I am using Eclipse with Red Editor plugin of Nokia.
*** Settings ***
Library Selenium2Library
Library DataDriver ${CURDIR}/data/login_data.xlsx DataDriven
Resource ${CURDIR}/resources/login_resources.robot
Suite Setup Open Browser To Login Page
Suite Teardown Close Browser
Test Setup Open Login Page
Test Template Invalid Login
*** Test Cases ***
Login With Invalid Data ${USERNAME} ${PASSWORD}
*** Keywords ***
Invalid Login
[Arguments] ${USERNAME} ${PASSWORD}
[Tags] Flat
Input Username ${USERNAME}
Input Pass ${PASSWORD}
Click Submit Button
Create HalfTrip Menu Should Not Be Open
In our application, when I navigate between web pages, system is showing attached Browser Confirmation Alert. I am using Robot framework to automate. I tried accepting or Dismissing the alert using 'Handle Alert' keyword. But i am observing 'Alert not found' error in report. Also right click is disabled to find web element in the Alert window.
*** Settings ***
Library Selenium2Library
Test Teardown Close Application
*** Variables ***
*** Test Cases ***
Dismiss Alert
Open Aplication
Click WebElement ${serchXpath}
Click WebElement ${navigateXpath}
Wait Until Element Is Visible ${Inv_xpath_all_rows} timeout=60 seconds
Handle Alert action=DISMISS timeout=60 s
Fails with : Alert not found in 5 seconds. at the line Handle Alert action=DISMISS timeout=60 s
I am new to Automation world, Request you to help me. Thanks a lot.
Looking at the screenshot of the popup attached, it looks like you are dealing with an "External Protocol Request" box. You cannot interact with this box using selenium webdriver API. Instead you need to handle this using ChromeOptions or by editing the Chrome profile. Here is a SO answer that describes how to go about it.
To handle the same in RobotFramework using Selenium2Library, check this out.
${chromeOptions}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${exclude}= Create Dictionary "fasp"=True
${prefs}= Create Dictionary protocol_handler.excluded_schemes=${exclude}
Call Method ${chromeOptions} add_experimental_option prefs ${prefs}
Create Webdriver Chrome chrome_options=${chromeOptions}
Source: https://support.asperasoft.com/hc/en-us/articles/216660968-How-to-unblock-the-launching-of-Connect-3-6-5-in-Chrome
Is it possible to write a test template with multiple keywords?
I'm looking for something like:
Valid Login
[Template]
Given login page is open
When ${username} and ${password} are inserted
and user is on ${device}
Then welcome page should be open
root abc desktop
noman xyz laptop
It would be a bonus if I could use a list instead of a data table
The normal way is to create a new keyword that calls those keywords, and set the template in the settings:
*** Settings ***
Test template Valid Login
*** Test cases ***
root abc desktop
noman xyz laptop
*** Keywords ***
Valid Login
[Arguments] ${username} ${password} ${device}
Given login page is open
When ${username} and ${password} are inserted
and user is on ${device}
Then welcome page should be open
The problem
I have a shiny application that requires user to login to access the underlying dataset.
The username and password are collected from form fields and submitted via a RESTful API on another server to get an access token which is used in future requests. I haven't included those details in this example.
I want to get the web browser to remember the login details and login automatically, but can't quite see how.
What I tried
In my first implementation, the <input type="text" name="username"> and <input type="password" name="password"> plus an actionButton were dynamically added to the page. This forced the user to re-login each time the shiny application was restarted, which was complex for development and unpleasant for users.
I then found https://gist.github.com/kostiklv/968927 which details the conditions for having the web browser remember the password and log in.
Shiny works on one page, so I couldn't have a separate login page (this would generate a new shiny session, discarding the login!).
I have tried various combinations of things, here is the closest I have got. This script correctly fills in a past password, but the user still has to manually hit submit.
Example code
Note that I have a custom hack my shiny in to enable type="password" to be treated the same as type="text". See bottom of question for access to this code
save this code as login.R then run R and type source("login.R")
write("","blank.html")
require(shiny)
addResourcePath("login",tools:::file_path_as_absolute("./"))
runApp(list(
ui=bootstrapPage(
tags$form(action="#",target="loginframe",
tags$input(id="username",type="text",placeholder="Username"),
tags$input(id="password",type="password",placeholder="Password"),
tags$input(id="loginButton",class="btn btn-primary",type="submit",value="Login")
),
tags$iframe(name="loginframe",src="login/blank.html",style="display:none")
),
server=function(input, output) {
observe({message(
"username ",input$username,"\n",
"password ",input$password,"\n"
)})
})
)
Analysis of what happened
Note that the presence of an html input submit button seems to tell shiny that it should only update the inputs once every submit. Without the submit button shiny updates its inputs every keystroke.
The same is true for shiny's submitButton.
Leaving the form but removing the button allows input$username and input$password to reach the server code, but...
To enable both conventional user login and automated login, I need the button to avoid repeated attempts to authenticate (which might cause problems) for partial usernames and passwords.
Log of what happened
Here are the console logs from the tests
Log with a submit button:
username
password
<enter username AA and password BB>
*no update*
<hit submit>
*browser requests to save password / yes*
username A
password B
<refresh page>
username
password
* onscreen form inputs are populated *
<hit submit>
username A
password B
Log without a submit button
Comment out
tags$input(id="loginButton",class="btn btn-primary",type="submit",value="Login")
and the preceding comma
note you may want to tell your browser to forget localhost web passwords for now.
username
password
<enter username AA and password BB>
username A
password
username AA
password
username AA
password B
password BB
<refresh browser>
* onscreen form inputs are not populated *
* browser requests to save password *
username
password
<refresh browser>
* onscreen form inputs are populated *
username
password
username AA
username BB
Shiny patch to enable password handling:
Install using library(devtools)
install_github("shiny","alexbbrown",ref="password-field")
Or download and install manually:
https://github.com/alexbbrown/shiny.git (branch password-field)
Or patch your shiny manually:
index 9b63c7b..15377d8 100644
--- a/inst/www/shared/shiny.js
+++ b/inst/www/shared/shiny.js
## -1336,7 +1336,7 ##
var textInputBinding = new InputBinding();
$.extend(textInputBinding, {
find: function(scope) {
- return $(scope).find('input[type="text"]');
+ return $(scope).find('input[type="text"],input[type="password"]');
},
getId: function(el) {
return InputBinding.prototype.getId.call(this, el) || el.name;
cf Password field using R Shiny framework
I was looking for something similar, and trestletech's fantastic package shinyStore worked for me.
It enables HTML5 client-side data storage for any data in your shiny app.
The github page is here, and an example of how it works is here.
You may wish to read the "Security" section on the README and ensure it is secure enough for your purposes.
I believe that you can use postForm() from RCurl package to perform a regular HTTP form submit request (unless Shiny would interfere with this functionality, which is based on using underlying libcurl library). For an example code, please see function srdaLogin() in my R module "getSourceForgeData.R": https://github.com/abnova/diss-floss/blob/master/import/getSourceForgeData.R.