How to make the browser allow notification disappear while running automate test using Robot Framework - robotframework

I don't want Allow Notifications pop up appear while I'm running automate script and I try to block it by manual (block it in browser setting). Browser is Firefox.
Test
[Tags] Regression
Open Excel ${Data.${ENV_DATA}}
#{getCustInfor}= Get Sheet Values CardNo
#{getMsg}= Get Sheet Values Messages
Login.Login by username and password ${USER.${ENV}} ${PASS.${ENV}}
The pop up always shows after finished login page and it cover some element.

Set the preference of firefox dom.webnotifications.enabled to False. This will disappear the notification.
In robot you can do this by, creating a function
def create_profile(self):
from selenium import webdriver
fp=webdriver.FirefoxProfile()
fp.set_preference("dom.webnotifications.enabled",False)
fp.update_preferences()
return fp.path
In .robot file add the following code:
${profile}= create profile
Open Browser ${URL} ${BROWSER} ff_profile_dir=${profile}

Related

How do I take a screenshot and close the browser after each test instance pass or fail?

I have a simple Tosca Test Case Template which takes data from a TestCaseDesign Sheet. The scenario is simple - It just launches the browser, navigates to a login page, enters username and password and clicks the login button. I have just two values for username and two values for password in the TestCaseDesign Sheet.
I linked the TestCaseDesign Sheet with the Test Case Template and generated two test instances.
Now, when I select and run these two test instances using the Scratchbook, I would like that the browser automatically closes after each test instance passes or fails so that the next test instance can open a new browser as a first step.
Also, I would like to take a screenshot before the browser closes.
How can I achieve that using Tosca?

Buffering a New url which is navigated on other page using tosca in run time

There is an website called X, When u click on the particular button from website X, it navigates in another tab with new url & i want to buffer that new url at run time. How to do in tosca?
I was able to successfully buffer a URL from IE. Here's how I did it.
First, I found this article on tricentis: https://support.tricentis.com/community/article.do?number=KB0015575
Following the instructions in that article, I scanned a new module for IE itself by selecting UIA during the scan (in the article). I captured the editbox of the URL bar as a module element.
Then, in a test case, I just used action-mode Buffer to read and store the URL into a buffer.

Select window created using JavaScript

In My Robot Script , After clicking on Edit Description link a window get opens (i.e. Java Script Window) Images here
Image 1::
Image 2:: Window image Along with Page Source
What i need is a. Select the window (java script)
b. Enter text into Text Area and click Ok.
I tried to use Select Window new/ Select window Description But control is waiting infinite # Select Window key word its not moving forward. I have to kill Control forcefully.
*** Settings ***
Documentation Suite description
Library Selenium2Library run_on_failure=Nothing
Library Collections
*** Test Cases ***
Log into Command center
[Tags] DEBUG
open browser http://11.8.180.***/BCC ie
input text xpath=//*[#id='LoginName'] User
input password Password Pwd#123
click element LoginBtn
wait until keyword succeeds 30 sec 5 sec page should contain element AppTitle
sleep 3s
${Title} Get Page Title
log ${Title}
Navigation to Usrs
Click on Window popup and enter text
CloseBrowser
close all browsers
*** Keywords ***
Click on Window popup and enter text
Click Link //*[#id="aspnetForm"]/table/tbody/tr[1]/td[2]/a
Sleep 5s
Select Window By Unique Identifier Element With Delay //*[#id="descript"]
Select Window By Unique Identifier Element With Delay
[Arguments] ${element} ${delay_time}=10
sleep ${delay_time}
#{wins}= Get Window Handles
Log ${wins}<--these are window names console=true
:FOR  ${windowName}  IN  #{wins}
\   Log ${windowName} console=true
\ run keyword and ignore error Select Window  ${windowName}
\   ${found_flag}= run keyword and return status page should contain  ${element}
\   Run keyword if ${found_flag} input text ${element} this is text
\   exit for loop if ${found_flag}
Get Page Title
Log Control came to GET PAGE TITLE
run keyword and return Get Title
Navigation to Usrs
Go to http://11.8.180.***/BCC/role.aspx
Any Idea how to select new window? and enter text hit okay.
A.Get Window Identifiers --> Jus hangs it neither moves nor throw any error
B. Get Window Names gives this error {URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>..}.
C. Get Window Handles returns this { [u'b0ce0f28-f6d4-4943-93f7-f65fd5f1de2a', u'c0442110-4ea9-40a4-b126-eee09d9f3eb0']}
I am not sure how to identify which window have these id's
Thanks in Advance
It should be recognized as new window in your browser, so you can use:
Select Window Description

How to simulate onblur event with Robot Framework

I am automating login scenario of an application.
The execution steps are as below:
Select the Country
Enter the Username
Enter the Password
Click on Login Button.
Actually after entered the username, application validates the country and username in database exists or not.
When tried to automate through robot framework, this validation is not called and so unable to login (actually login button is clicked through script, but no error message or no response user is in same page).
When i verified exact scenario it calling the validation, comes to know that
validation is called on onblur of the usename element onblur="getlocation()".
I tried to simulate this by give tabout from username field through script as
Press Key ${element path} \\9 but it is not working always out of 10 run only 3 or 4 times it working.
Is there any way we can do 'blur` action on the element in robot framework
In the Selenium2Library for robot, there is a special keyword for that:
Simulate <element> <event>
In my keyword definition it looks like this:
I Enter The New Password
[Arguments] ${text}
Input Text ${INPUT_ELEMENT_PASSWORD} ${text}
Simulate ${INPUT_ELEMENT_PASSWORD} blur
http://robotframework.org/Selenium2Library/Selenium2Library.html#Simulate
I hope that helps, it took us a while to figure out what was missing in the test.
Just to save few minutes of googling.
Simulate
is deprecated. Use
Simulate Event
instead

AutoIt send command in IE in Kiosk mode

I'm really new to coding (like very new) but I managed to do what I wanted with AutoIt. That means: Launch IE automatically on a certain web page in Kiosk mode. So far so good.
But before I was not in kiosk mode the input sent worked but now I can't find the problem why it does not work any more.
ShellExecuteWait("c:\Program Files\Internet Explorer\iexplore.exe", "-k http://website.com", "")
WinWaitActive("website.com  Login - Internet Explorer","")
Send("login{TAB}password{ENTER}")
The website is launched, I'm directly in the login box, but nothing is typed in it. Any ideas?
Like #Steve said in the comments, you can try to use ControlFocus when the window is shown, then send the credentials.
ShellExecuteWait("c:\Program Files\Internet Explorer\iexplore.exe", "-k http://website.com", "")
; store the returned window handle to use it in the ControlFocus call
Local $hWnd = WinWaitActive("website.com Login - Internet Explorer","")
ControlFocus($hWnd, "", "Edit1")
Send("login{TAB}password{ENTER}")

Resources