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

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?

Related

How can I print my mock data on the screen?

I want to write a test on my homepage.
First of all, I created a function called setup and got my provider and routes here.
Then I enter the value in my input and wait for my mock data on the screen, but no product is printed on the screen.
home/index.test.tsx
home/index.tsx
It gives an error because there is no product on the screen, so it says I couldn't find it.
I mocked my api these tests are passing screenshot of my code

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.

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

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}

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

link btn re-direct holding session variable

I want to use a link button to run a function 'LoadCheckListRecordEntry' which sets a session and re directs the user...However the page seems to be loading be the session is set??
ALthough the html is running the code b4 the 'DiaryEntId' actually gets set, so it returns null in the LINQ...How can i resolve this?

Resources