You are on page 1of 13

How can we pass different browser at once in

robotframework
*** Variables ***

${BROWSER} firefox
${URL} http://url/
${Delay} 0
in my settings.txt file i have a variable named {BROWSER} AND associate
value as shown above it is firefox

but what i want is

*** Variables ***

@{BROWSERS} firefox chrome IE


${URL} http://url/
${Delay} 0
something like above... so when i run test-suite first it will run in firefox
and after completion of all testcases it will close firefox and will open
chrome and run all the test cases again on chrome browser ..and so on
after this it will run on IE

so how could we do this?

I don't want to do it manually (I mean by passing one by one or by editing


txt file). fully automatically.... once i run the test it will automatically test
in all the browsers.

PS: this is in settings.txt file and i have two folders in which i have
test.txt files. so there is the main problem ..i have to iterate these folders
in a loop

|-- main.py
|-- settings.txt //in this file i have browser variable (or Array)
|-- test1
| |-- testl.txt
| |-- test1_settings.txt //this will contain all the variables and user defined keyword
related to test1 and
|-- test2
| |-- test2.txt
| |-- test2_settings.txt //same as test1
i run test cases like this $pybot test1 test2

I see 2 ways to do it.

1) loop over your browser and call a keyword that do your test:

*** Variables ***


@{BROWSERS} firefox chrome IE

*** test cases ***


test with several browser
:FOR ${browser} IN @{BROWSERS}
\ log to console call keyword that does your test with ${browser}
Here is what you get with this test:

[Mac]$ pybot .
Browser.Ts
======================================================================
========
test with several browser
call keyword that does your test with firefox
call keyword that does your test with chrome
call keyword that does your test with IE
test with several browser | PASS |
------------------------------------------------------------------------------
Browser.Ts | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
======================================================================
========
2) another way (which I prefer) is to keep your ${BROWSER} variable with
a single value and call your test case several time with a new value for
the variable that you give on the command line:

[Mac]$ pybot --variable BROWSER:firefox ts.txt


[Mac]$ pybot --variable BROWSER:chrome ts.txt
[Mac]$ pybot --variable BROWSER:ie ts.txt

Ok I think I've solved this problem by writing a simple script.

I Just wrote a program which will read the file settings.txt and find the
line @{BROWSER} firefox chrome IE and then extract browsers name and
store into a list . so this script will return a List something like this
['firefox', 'chrome', 'IE']
now instead of using single pybot command I'll use it in a Loop

for browser in browsers:


call(['pybot','--variable'] +['BROWSER:%s'%browser] + test_args)
settings.txt file will contain two variable

${BROWSER} firefox #So default browser is firefox. you can leave it blank
@{BROWSERS} firefox chrome IE
Q #2) What all things can you automate?
The right candidates for automation are:

 Regression test suite


 Smoke / Sanity test suite
 Build deployment
 Test data creation
 Automating behind the GUI like testing of APIs and methods
Q #3) How do you identify the test cases which are suitable for automation?
Identify the appropriate test cases for automation is the most important step towards
automation.
Q #4) Can you achieve 100% automation?
100% automation would be difficult to achieve because there would be many edge test
cases and some cases which are executed seldom. Automating these cases which are not
executed that often will not add value to the automated suite.

Q #5) Currently I do not have any automation in place in my project, now I want


to implement automation, what would be my steps?
 First, identify which type of testing/test cases you want to automate
 Identify the tool
 Design the framework
 Create the utility files and environment files
 Start scripting
 Identify and work on the reporting
 Allocating time for enhancing and maintaining the scripts.
Q #6) How do you decide which tool you have to use?
Concluding which tool is best suitable for the project requires a lot of brainstorming and
discussions.
Q #7) Once you identify the tool what would be your next steps?
Once we finalize the tool, our next step would be to design the framework.

Q #8) What is a framework?
A framework is a set of a structure of the entire automation suit. It is also a guideline if
followed can result in a structure which is easy to maintain and enhance. These guidelines
include:

 Coding standards
 Handling the test data
 Maintaining and handling the elements (object repository in QTP)
 Handling of environment files and properties file
 Reporting of data
 Handling logs
Q #9) What are the attributes of a good framework?
The characteristics are:

 Modular – The framework should be adaptable to change. Testers should be able to


modify the scripts as per the environment or login information change
 Reusable – The commonly used methods or utilities should be written in a common
file which is accessible to all the scripts.
 Consistent – The suite should be written in a consistent format by following all the
accepted coding practices.
 Independent – The scripts should be written in such a way that they are independent
of each other. In case one test fails, it should not hold back remaining test cases
(unless it is a login page)
 Logger – It is good to have implemented the logging feature in the framework. This
would help in case our scripts run for longer hours (say nightly mode), if the script
fails at any point of time, having the log file will help us to detect the location and
the type of error.
 Reporting – It is good to have reporting feature automatically embedded into the
framework. Once the scripting is done, we can have the results and reports sent via
an email.
 Integration – Automation framework should be such that it is easy to integrate it
with other application like continuous integration or triggering the automated script
as soon as the build is deployed.
Q #10) Can you do without a framework?
Frameworks are guidelines and not mandatory rules, so we can do without a framework, but
if we create it and follow it, enhancing and maintaining would be easy to implement.

Q #11) What are the different types of automation tool you are aware of?
Open source tool   like Selenium, JMeter

Paid tools like QTP, Load Runner, Ranorex, RFT, and Rational Robot.

Q #12) What generally is the structure of a framework?


Normally the structure should have – (It would differ from project to project)

 A “src” (source) folder having the actual test scripts


 A”lib” (library) folder having all the libraries and common methods
 A “class” folder having all the class file (in-case using java)
 A “log” folder having the log file(s)
 A file/folder having all the web element Ids
 A file containing the URL, environment and login information.
Q #13) Where you maintain information like URL, login, password?
This information should always be maintained in a separate file.

Q #14) Why do you want to keep this kind of information in a separate file and not
directly in code?
URL, Login, and passwords are the kind of fields which are used very often and these
changes as per the environment and authorization. In case we hardcode it into our code, we
have to change it in every file which has its reference. In case there are say more than 100
files, then it becomes very difficult to change in all the 100 files and hence can lead to
errors. So this kind of information is maintained in a separate file so that updating becomes
easy.

Q #15) What are the different types of frameworks?


Different types of framework available are:
 Keyword driven framework
 Data Driven framework
 Hybrid Framework
 Linear Scripting
Q #16) Can you tell some good coding practices while automation?
Some of the good coding practices include:

 Add appropriate comments


 Identify the reusable methods and write it in a separate file
 Follow the language-specific coding conventions
 Maintain the test data in a separate file
 Run your scripts regularly
Q #17) Any kind of test which you think should not be automated?
 Tests which are seldom executed
 Exploratory testing
 Usability testing
 Test which is executed fairly quickly when done manually
Q #18) Do you think that testing can be done only at the UI level?
Today as we are moving to Agile mode, testing is not limited to the UI layer. Early feedback
is imperial for an agile project. If we concentrate only on the UI layer, we are actually
waiting until the UI is developed and available to test. Rather we can test even before the
UI is actually developed. We can directly test the APIs or the methods using tools like
Cucumber and FitNesse.
In this way, we are giving the feedback much early and even are testing before the UI is
developed. Following this approach will help us to test only the GUI aspect of small cosmetic
changes or some validations on the UI and will help the developers by giving more time to
fix the bugs.

Q #19) How do you select which automation tool is best suited for you?
Selecting the automation tool depends upon various factors like:

 The scope of the application which we want to automate


 Management overhead like cost and budget
 Time to learn and implement the tool
 Type of support available for the tool.
 Limitation of the tool
Q #20) What do you think holds testers back to do automation? Is there a way to
overcome it?
The major hurdle for testers is to learn programming/coding when they want to automate.
Since testers do not code, adapting to coding is a bit challenging for testers. We can
overcome it by:
Collaborating with developers when automating
Considering that automation is the responsibility of the whole team and not only of
the testers
 Giving a dedicated time and focus on automation.
 Getting proper management support.
You can save these automation testing interview questions as pdf and print for further
reading.

Conclusion:
Most of the test automation interview questions are centered on the framework you
develop, so it is recommended that you create and understand your test framework
thoroughly. When I am interviewing, and the candidate has answered my question on the
framework, I also prefer asking language specific question (core java in my case).

The questions start from basics of java to write the logic of some basic scenario like –

 How would you extract a set of text from a given line?


 How would you extract URL?
 In any web page, at any frame, the number of links and its content change
dynamically, how would you handle it?
 How do you handle images and flash objects?
 How do you find a word in a line?
As far I know, for a 2 year experience at Automation testing using Selenium, they would
probably expect you to understand the tool as a whole and it’s underlying programming
language being used such as: Java, Python, C# etc…

In one of the interviews, I had attended for this profile. Below, were being asked (Had
mentioned it my resume, that I am having an experience of ~2 years on Selenium)

Note: I will write it as ‘general topic’ as I do not remember much on the exact questions
being asked

1. Xpath - Relative and Absolute.


2. Different type of ‘selectors’ used.
3. Gave a scenario and enquired on how to navigate to the exact location using
Xpath even if the ‘HTML tag’ being used is dynamic in nature ( Whenever, we
open a page, the ‘HTML tag’ for that field, will change every time)
4. Capturing screenshot and reports.
5. TestNG and JUnit
6. Usage of any third party tools and integrating it with Selenium such as :
Auto-IT, Sikuli, Jenkins, ANT etc…
7. Usage of any repository such as : GitHub etc…
8. Different wait functions such as : Implicit Wait, Explicit Wait, Fluent Wait,
WebDriver wait
9. Usage of any Automation framework or if given a chance, ‘Have I built and
how’
10. Capturing all the values in a dropdown/table and displaying it as output -
Usage of Java collections.
11. Window Handling i.e. Handing of different tabs, new window
12. Downloading and saving a file from any browser.
13. Robot Class - (This is used to simulate Keyboard and Mouse functions)
14. Sending a value from excel to the UI during runtime - Apache POI
15. Some questions related to your programming language used
a. Polymorphism
b. Inheritance
c. Java Collection
d. Classes and Objects - Accessing in different packages.
(I use Java, Hence, they asked me only in that language)

I have written based on my experience in an interview. Could not recollect the exact
questions being posed to me, Hence wrote it as general topic they covered.

Hope this helps

Which challenges can destroy your efforts in automated testing?

Explore what make 52% of test project managers fail in executing their automation
testing projects.

Top 50 Selenium Interview Questions for testers having 2+ years of


experience:

1. What are the annotations used in TestNG?

@Test, @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass,

@BeforeMethod, @AfterMethod

2. How do you read data from excel?

FileInputStream fis = new FileInputStream (“path of excel file”);

Workbook wb = WorkbookFactory.create (fis);

Sheet s = wb.getSheet (“sheetName”)


String value = s.getRow (rowNum).getCell (cellNum).getStringCellValue ();

3. What is the use of xpath?

It is used to find the WebElement in web page. It is very useful to identify the dynamic web
elements.

4. What are different types of locators?

There are 8 types of locators and all are the static methods of the By class.

• http://By. id ()

• http://By .name ()

• By.tagName ()

• By.className ()

• By.linkText ()

• By.partialLinkText ()

• By.xpath

• By.cssSelector ()

5. What is the difference between Assert and Verify?

Assert it is used to verify the result. If the test case fails then it will stop the execution of the
test case there itself and move the control to other test case.

Verify it is also used to verify the result. If the test case fails then it will not stop the
execution of that test case.

6. What is the alternate way to click on login button?

Use submit () method but it can be used only when attribute type=submit.

7. How do you verify if the checkbox/radio is checked or not?

We can use isSelected () method.

Syntax – driver.findElement (By.xpath (“xpath of the checkbox/radio button”)).isSelected


();

If the return value of this method is true then it is checked else it is not.

8. How do you handle alert popup?


To handle alert popup, we need to 1st switch control to alert popup then click on ok or
cancel then move control back to main page.

Syntax:

String mainPage = driver.getWindowHandle ();

Alert alt = driver.switchTo ().alert (); // to move control to alert popup

alt.accept (); // to click on ok.

alt.dismiss (); // to click on cancel.

//Then move the control back to main web page

driver.switchTo ().window (mainPage); → to switch back to main page.

9. How do you launch IE/chrome browser?

Before launching IE or Chrome browser we need to set the System property.

//To open IE browser

System.setProperty (“http://webdriver.ie.driver”,”path of the iedriver.exe file”);

Web Driver driver = new InternetExplorerDriver ();

//To open Chrome browser → System.setProperty (“webdriver.chrome.driver”,”path of the


chromeDriver.exe file”);

WebDriver driver = new ChromeDriver ();

10. How to perform right click using WebDriver?

Use Actions class

Actions act = new Actions (driver); // where driver is WebDriver type

act.moveToElement(WebElement).perform();

act.contextClick ().perform ();

11. How do perform drag and drop using WebDriver?

Use Action class

Actions act = new Actions (driver);

WebElement source = driver.findElement (By.xpath (“”)); //source ele which you want to

drag
WebElement target = driver.findElement (By.xpath (“”)); //target where you want to drop

act.dragAndDrop(source, target).perform();

12. Give the example for method overload in WebDriver.

Frame (string), frame (int), and frame (WebElement).

Hi ,

Below are the questions that are generally asked during interviews in any automation
testing company to someone who has around 2 years experience in Automation testing
using selenium

1. Concepts of Selenium and language using for Automation preferably Java.


2. Real time challenges faced in your current project during Automation and
execution of functional test cases
3. Approach for execution of automation suites and analysis of failed test cases
4. Different type of Automation frameworks along with pros and cons
5. Innovations done in the framework
6. Handling elements using different attributes like ID, xpath, css etc
7. Understanding of various concepts Maven, Ant,Jenkins, that have been
integrated in Automation frameworks
8. Coding and naming conventions using in Automation scripts
9. Logic skills to test your ability to automate complex test cases
10. Communication skills to ensure that you can explain the execution report
details to clients & respond to queries
11. and many more..
Basically, since they will try to analyze if you can write Automation scripts effectively

There is ko specific set of questions that I can point to as it depends on the company and
the interviewer but still I will try to give few general topics you can prepare for before
attending any interview

1. Read about different locators (advantage, performance)


2. Creating xpath
3. Handling pop windows, alerts, tabs
4. Common exceptions in selenium
5. Challanges faced with selenium
6. Handling non browser winds(like file browser)
7. Waits types and differences
8. Framework(structures, data handling, design patter i.e. POM,etc)
9. Advantage of using POM
10. Bit knowledge on OOPS concepts (Array, string, exception handling, Maps)
These are the topics I can think of right now might be I am not covering everything so
taking help from this you can start your prep and add things if you come across it on the
way.

If you need any help with any of the topic you can contact me I will be happy to help you.

#1) What is Automation Testing?

Automation testing or Test Automation is a process of automating the manual process to


test the application/system under test. Automation testing involves use to a separate
testing tool which lets you create test scripts which can be executed repeatedly and
doesn’t require any manual intervention.

Q #2) What are the benefits of Automation Testing?

Benefits of Automation testing are:

1. Supports execution of repeated test cases


2. Aids in testing a large test matrix
3. Enables parallel execution
4. Encourages unattended execution
5. Improves accuracy thereby reducing human-generated errors
6. Saves time and money
Q #3) Why should Selenium be selected as a test tool?

Selenium

1. is free and open source


2. have a large user base and helping communities
3. have cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari
etc.)
4. have great platform compatibility (Windows, Mac OS, Linux etc.)
5. supports multiple programming languages (Java, C#, Ruby, Python, Pearl
etc.)
6. has fresh and regular repository developments
7. supports distributed testing
Q #4) What is Selenium? What are the different Selenium components?

Selenium is one of the most popular automated testing suites. Selenium is designed in a
way to support and encourage automation testing of functional aspects of web-based
applications and a wide range of browsers and platforms. Due to its existence in the
open source community, it has become one of the most accepted tools amongst the
testing professionals.

Selenium is not just a single tool or a utility, rather a package of several testing tools and
for the same reason, it is referred to as a Suite. Each of these tools is designed to cater
different testing and test environment requirements.
This is regarding interview questions using selenium and Java in Delhi-Ncr
organizations

 first of all questions would related to your current project, which framework
are you using & why, how & where you are initiating Driver, what is the
structure, draw the structure with block diagrams
 How will you click on link inside a menu which is shown only when mouseis
hovered over it.
 What is the difference between findelement and findelemets
 What is the difference between implicit, explicit and fluent wait
 How can you click on an element other than using the click function
 How will you handle windows based popup
 How will you take a screenshot
 How will you read and write excel files
 Scenario based questions on xpath, like how would you form the xpath of
this element-any scenario
 Questions would be on your programming skills, like reverse a string, find
missing elements in an array
 Questions would also be there on testNG, like what is dataprovider, what is
the order of execution of different methods, how would you exclude and
include different methods
 If you are using Java, then questions coudl be on keywords like static, final,
finally, difference between abstract and interface, questions on collections like
difference between list and arraylist etc.
 If you are using Maven and CI tools then questions might also be asked using
them.
I have been giving interviews from last 1 year and these are the questions which have
been asked mostly

it varies from place to place,

But some general questions are,

1. What is Software Testing Life cycle.


2. How do you handle windows based pop up in selenium?
3. What are the Exceptions we get in selenium?
4. What is the difference between driver. close() ; and driver. quite() ;
5. What is Maven?
6. What is data driven Testing?
7. Basics about Jenkins
8. How do you handle frames?
9. Questions from your Resume.
Hope this helps you :)

You can find more information at:

You might also like