Selenium Interview - A basic guide
One of my friend recently had to attend an interview for a company for a selenium - tester job profile. Then he asked me, what should I prepare for? Then I thought of putting together this post, as selenium is now an industry accepted tool.
Simple explanations
What is Selenium ?
- Its a web testing tool.
How it works?
It works through a proxy, using javascript to driver the tests.
What browsers does it support?
Firefox - 3.0/2.0
IE - 7/8
Safari
What programming languages can you use to write the tests?
Language | Selenium IDE | Selenium Remote Control | Selenium Core |
---|---|---|---|
C# | Generate code | Library ("driver") support | n/a |
Java | Generate code | Library ("driver") support | n/a |
Perl | Generate code | Library ("driver") support | n/a |
PHP | Generate code | Library ("driver") support | n/a |
Python | Generate code | Library ("driver") support | n/a |
Ruby | Generate code | Library ("driver") support | n/a |
Preparing for Interview
Tips :
1) Understand the basics right :
- Basics of Web testing
- How selenium works? - http://seleniumhq.org/about/how.html
- Selenium API - http://seleniumhq.org/documentation/core/reference.html#actions
2) How selenium Indentifies web element on the page?
- By Id or Name or Using an Xpath
3) Different Flavours of selenium
- Selenium Core
- Selenium RC
- Selenium Grid
4) Selenium - How to use IDE?
5) Is IDE good enough to automate your tests?
6) What are the practical issues, while using selenium?
7) Selenium Vs Other tools (Like QTP)
8) Multi browser testing with selenium (Or Selenium Grid)
Automation Testing - Traditional to Agile
I always wonder, how the face of automation testing has changed over the years. Automation testing has always been perceived as post development, costly activity to be done by specialists.
Agile methodology has broken all the barriers/Myths of automation testing. From a heavy weight , System level , Regression oriented process to Acceptance oriented, all level light weight process.
In traditional projects, automation is only used as regression testing tool, and always perceived as to be done after "Stabilisation of the product"
Automation in agile projects becomes inevitable as its a mean to reduce the feedback cycle. it reduced the regression cycle, and helps producing quality code with higher pace. it also helps system to be robust all the time.
Unlike traditional project automation, which is only participated by specialist, in agile projects automation is practiced at all levels (Unit, System, Integration) by all stake holders of the project in one form or another.
In Agile methodology, automation tests are treated and take care as part of the overall source code. It needs the same love and care as any other piece of code in the project.
Automation in agile project is not just about automating the test cases, but automation is any mean to convert manual process to reduce the time waste or to add value in overall process.
Testing - When, Where and How on agile projects....
I think this question haunts most of the agile QA's mind. I am going to wrote something in this post from my previous experience.
As agile is not a fixed set of processes, so its is imperative to be agile in testing as well. However, some practices help..but again everything is contextual.
1) Adding value early : Agile testing is all about giving feedback early, not necessarily only by testing the software, but in different ways as well.
a) Looking at requirements for Clarity and Testability - QAs really need to look at the requirement / stories upfront to figure out that requirement are unambiguous and testable.
Unambiguous . - I think unambiguous in agile has little different context compared to typical waterfall project.
- Requirement should be small enough to make sense in the context
- Acceptance criteria (Stories are generally broken in to acceptance criteria) should not be duplicate or overlapping from different stories.
However, doing that can be really difficult and can only be achieved with really good communication between Dev/BA/QA.
Testable : Testability aspect of the story requires QA to scan through the story to see what needs to be done to test the story. These factors can generally be.
- Finding hidden requirements
- Environment
- Test data
- Dependency on other requirement.
Getting these details early helps the story to be prioritised accordingly in the backlog, and allows smooth execution of the story in the iteration.
2) Use Automation to the advantage not for sake of doing it
Automation in agile is quiet controversial, as people try to automated everything and end up having a long feedback cycle.
Automation is meant for giving early feedback on the latest code, and automation should be limited to what is worth Automating and what is not.
Every automation test written has a cost against it. The cost can be seen as
Cost of continuously running it (Increased feedback cycle). This cost should be compared against cost of not runing it. So, a question needs to be asked what if a test is not written? what we gonna lose, what would be the cost of fixing the stuff around the code for which we are losing the coverage?
And this might not be straight forward finding the worth of a test. Its a contextual decision and also depends on size of the project and number of people involved in it.
Simply putting this in other words mean :
Longer feedback cycle = More people losing time in getting instant feedback.
I will write posts on - How to write automated acceptance tests in my future posts.....
This post to be continued
Twist - Still waiting for GA
I am still waiting for Twist GA to continue my series on Twist features.
Till then I want to keep my mouth shut...
How much to test?
That's a question needs to be answered very early in any agile project.
Testing costs time and money, and no doubts adds value. Then how do we get a balanced approach on testing the user stories..
These questions should be answered while writing automated test for Acceptance critera
1) Is it too low level of testing...?
- Do I really need to check a particular link is present or not...?
2) Are there repeating tests with some diversity?
- Can it be compromised over quick turnaround of the build?
3) How do we mitigate the risk of writing less tests?
- Can we make tests precise ?
- Can we not automate unit level tests in Accpetance test.
To be continued...
Twist - Using other drivers
Twist can be used with other available drivers in Java for web . W ehave recently tried using webdriver to migrate some of our tests and effort was painless.
Twist allows injection of other drivers using spring. So, that means without changing the definition of the scenario the underlying code can be chaned.
Also, Selenium 2.0 is going to be webdriver primarily, so seems twist will be even powerful in coming days.
Using your customised messages in Twist assertions.
I am sure many of you would have felt the need of what I am going to write. Since, Twist uses Junit assertions methods for the assertions, so as it is dependent on Junit to pass on the error messages in case of failures.
Take an example where I am verifying a value of textbox name "Username" and use a Jnunit assertion like
assertEquals (Expected, seleneium.getText("Username"));
In case this step fails, it is going to show like ..
"Expected ['xyz'] but was ['yxz']", but this does not give me any information of the application context.
This becomes even more difficult, when we have a large test suite of big tests and looking at error message it is dificult to figure out, what failed exactly?
So, I would like to see an error message for the above example like -
"Username text expected[xyz], but was [yxz]", and this can be achieved by passing a context (String parameter), to the assertEquals method and then it will generate an error message with the context (Sring parameter). SO, I change the above bit of code to look like this....
assertEquals ("Username text", Expected, seleneium.getText("Username"));
And when this assertion fails, it will generate the error message in more meaning way, and also Twist HTML report will also change accordingly.
This is the simplest way we could do it so far, but I am sure Twist team is working on having its own assertion libraries and I am looking forward to that.
Take an example where I am verifying a value of textbox name "Username" and use a Jnunit assertion like
assertEquals (Expected, seleneium.getText("Username"));
In case this step fails, it is going to show like ..
"Expected ['xyz']
This becomes even more difficult, when we have a large test suite of big tests and looking at error message it is dificult to figure out, what failed exactly?
So, I would like to see an error message for the above example like -
"Username text expected
assertEquals ("Username text", Expected, seleneium.getText("Username"));
And when this assertion fails, it will generate the error message in more meaning way, and also Twist HTML report will also change accordingly.
This is the simplest way we could do it so far, but I am sure Twist team is working on having its own assertion libraries and I am looking forward to that.
Project Migration in new Twist Beta
If you are using an older version of Twist Beta and want to migrate your test, you need not worry too much about it.
As soon as you open your project in the new Twist Beta, it will ask you to migrate the project. However, there is a manual option also available to migrate the project. (Right click on Twist project -> Migrate ).
It will update applicationcontext-suite.xml and twist.properties files, also it will add a folder names twist-conf with three configuration files in it.
As soon as you open your project in the new Twist Beta, it will ask you to migrate the project. However, there is a manual option also available to migrate the project. (Right click on Twist project -> Migrate ).
It will update applicationcontext-suite.xml and twist.properties files, also it will add a folder names twist-conf with three configuration files in it.
New Twist Beta Update
We have upgraded ourselve to the new Twist Beta.
And this comes with some cool features.
- Inline Reporting
- Proxy settings
I have already spoken about this in my previous posts.
- Automatic variable assignment to an UI object while recording.
The way we have Incorporated the object repository concept in Twist by creating a single Java file to hold all the object information.
Rather then using object definitions directly in the script, which makes them brittle and hard to manage, we use the objects from the repository. If something changes about that object, we know where exactly to find that object, and also that avoids making thousand changes if that particular object is being used quiet a lot.
And last not the least, recorder seems to be improved in the new Beta version and its really stable so far.
And this comes with some cool features.
- Inline Reporting
- Proxy settings
I have already spoken about this in my previous posts.
- Automatic variable assignment to an UI object while recording.
The way we have Incorporated the object repository concept in Twist by creating a single Java file to hold all the object information.
Rather then using object definitions directly in the script, which makes them brittle and hard to manage, we use the objects from the repository. If something changes about that object, we know where exactly to find that object, and also that avoids making thousand changes if that particular object is being used quiet a lot.
And last not the least, recorder seems to be improved in the new Beta version and its really stable so far.
Twist - Bits - How to check selected value of a dropdown?
assertEquals(value, selenium.getSelectedLabel(locator));
Twist creating a Generic Checkpoint Method
public void applyCheckpoint(String propname, String locator,String valueToVerify)
{
String locatorWithAttribute =locator+"@"+propname;
Assert.assertEquals(selenium.getAttribute(locatorWithAttribute), valueToVerify);
}
{
String locatorWithAttribute =locator+"@"+propname;
Assert.assertEquals(selenium.getAttribute(locatorWithAttribute), valueToVerify);
}
Twist can now talk to Proxies
May be little early to post as official build is not GA yet.
But I got to test the latest build, and now Twist can work on external proxies. :)
However, there are few changes needs to be mad eto twist.propeerties file and applicationContext-suite.xml.
1) Changes to twist.properties
Though I personally beleive user should not worrry about setting the URL at settings level, as this is contextual thing and I have to switch this setting everytime I need to record on a new application. (Little bit of Pain).
However, I am happy to take this pain in lieu of having Twist working with proxies at the moment.
How to set the Proxy settings ?
2) Changes to applicationContext-suite.xml.
Change the follwing bean tags
bean id="systemproperty"
"entry key="http.proxyHost" value="www.proxy.url""
"entry key="http.proxyPort" value="8080""
"entry key="http.proxyUser" value="""
"entry key="http.proxyPassword" value="""
(Sorry for unformatted XML, as it might not appaer in it's original form)
But I got to test the latest build, and now Twist can work on external proxies. :)
However, there are few changes needs to be mad eto twist.propeerties file and applicationContext-suite.xml.
1) Changes to twist.properties
- selenium.server.options = -port 4545 -avoidProxy
- selenium.browserLauncher=*firefox
- selenium.browserURL=http://www.xyz.co.uk
Though I personally beleive user should not worrry about setting the URL at settings level, as this is contextual thing and I have to switch this setting everytime I need to record on a new application. (Little bit of Pain).
However, I am happy to take this pain in lieu of having Twist working with proxies at the moment.
How to set the Proxy settings ?
2) Changes to applicationContext-suite.xml.
Change the follwing bean tags
bean id="systemproperty"
"entry key="http.proxyHost" value="www.proxy.url""
"entry key="http.proxyPort" value="8080""
"entry key="http.proxyUser" value="""
"entry key="http.proxyPassword" value="""
(Sorry for unformatted XML, as it might not appaer in it's original form)
Twist - Creating a Google Test
- Create a Twist Project, by clicking on File - New - Twist Project.
- A wizard will be opened, Enter a project name and choose advanced option to selenium driver. (That's the driver needed for web testing)
- Leave other options unchanged, if you want selenium server to run on another port change the port number.
Once Project is created , It will ask you to create a new scenario, enter some name to it and click on Finish.
To make it a executable test, one need to create a work flow.
- Click on Work flow button on top of the test, it will add a blank scenario something like.
New Work flow:
A bullet point will also be inserted, specifying that as scenario step.
- Change the scenario name if needed and then put the cursors on scenario name to make it executable.
- Click "Ctrl+1" to create a workflow (That is java class with the workflow name), after that is done the color and font style of the workflow name will be changed to Black and Normal from Italic respectively. It denotes that workflow has been created, however there are no tests specified in that.
- Now create test steps - Create one test step each against a bullet point.
Once Testing steps are defined, one need to elaborate them to make it executable.
Sale rule as we did with workflow, put the cursor on the step name and click "Ctrl+1", it will give two options
1) To create the blank method in the Java class created above.
2) To record the method using "Firefox " (Does not support any other browser for recording at the moment).
If option 2) is selcted then a browser is launched and user can perform actions ..
Lets record out first step - 1) Open website "www.google.co.uk"
Once the browser is launched, type "www.google.co.uk", and then to mark the recording finished click on "Done" on recording pane (Can be seen on right hand side).
Now, Twist must have inserted some code for this methods 1) Open website "xxx"
Code can be seen by pressing "F3" on the method name, it will then navigate to the specific method , by highlighting the method in the code.
That's what we get in the code..
public void openWebsite(String string1) {
selenium.open("www.google.co.uk");
}
Now, this method can be made reusable by using parameter string1, that is the google url in the test, instead of using hard coded value. So, now the method would look like.
public void openWebsite(String url) {
selenium.open("url);
}
Now, this method can be used to open any URL..
- A wizard will be opened, Enter a project name and choose advanced option to selenium driver. (That's the driver needed for web testing)
- Leave other options unchanged, if you want selenium server to run on another port change the port number.
Once Project is created , It will ask you to create a new scenario, enter some name to it and click on Finish.
To make it a executable test, one need to create a work flow.
- Click on Work flow button on top of the test, it will add a blank scenario something like.
New Work flow:
A bullet point will also be inserted, specifying that as scenario step.
- Change the scenario name if needed and then put the cursors on scenario name to make it executable.
- Click "Ctrl+1" to create a workflow (That is java class with the workflow name), after that is done the color and font style of the workflow name will be changed to Black and Normal from Italic respectively. It denotes that workflow has been created, however there are no tests specified in that.
- Now create test steps - Create one test step each against a bullet point.
- Open website "www.google.co.uk"
- Enter search criteria "Testing"
- Verify Search Result "Testing"
Once Testing steps are defined, one need to elaborate them to make it executable.
Sale rule as we did with workflow, put the cursor on the step name and click "Ctrl+1", it will give two options
1) To create the blank method in the Java class created above.
2) To record the method using "Firefox " (Does not support any other browser for recording at the moment).
If option 2) is selcted then a browser is launched and user can perform actions ..
Lets record out first step - 1) Open website "www.google.co.uk"
Once the browser is launched, type "www.google.co.uk", and then to mark the recording finished click on "Done" on recording pane (Can be seen on right hand side).
Now, Twist must have inserted some code for this methods 1) Open website "xxx"
Code can be seen by pressing "F3" on the method name, it will then navigate to the specific method , by highlighting the method in the code.
That's what we get in the code..
public void openWebsite(String string1) {
selenium.open("www.google.co.uk");
}
Now, this method can be made reusable by using parameter string1, that is the google url in the test, instead of using hard coded value. So, now the method would look like.
public void openWebsite(String url) {
selenium.open("url);
}
Now, this method can be used to open any URL..
Twist - Next Step
Today we moved our Twist project to SVN, and let me admit that movement to SVN and checking out the project was pretty smooth.
However, we did see an issue, we had changed the project name while checking out the project. In that case it would not show the Auto suggestion for already existing methods. (See the Pic..).
Twist allows you to reuse any existing action from across the tests. For e.g> If i had defined a a method to open a URL for my tests, I can simply reuse it with passing different URL as parameter.
In my next post I will explain how to create a basic test in twist.....
Twist - Learnings
We have started looking out to use Twist for this project we are currently doing for a client.
Twist is a tool for Automated acceptance testing by ThoughtWorks. The power of Twist is in the simplicity of the tool. Twist is built upon the Eclipse IDE which is a Java IDE.
One can write the Tests in English like syntax and then it can be extended to define the logic behind these English sentences.
It allows you to reuse the previously used sen tenses/test components in a very easy and Intuitive way.
I will keep posting my leanings on this..
Twist is a tool for Automated acceptance testing by ThoughtWorks. The power of Twist is in the simplicity of the tool. Twist is built upon the Eclipse IDE which is a Java IDE.
One can write the Tests in English like syntax and then it can be extended to define the logic behind these English sentences.
It allows you to reuse the previously used sen tenses/test components in a very easy and Intuitive way.
I will keep posting my leanings on this..
Agile Testing - Few facts
- In an agile team Quality is “everyone's responsibility”.
- QA team continuously measures the Quality and provide the feedback.
- Role of QA changes many times within the life cycle of the Iteration.
- Test Automation is used to eliminate the time waste and Increase the Test coverage for “Any time Regression”.
- Automation helps QA’s to focus on exploratory testing, as one can focus on other important stuffs.
- Quality is not added later, it evolves gradually.
| Traditional | Agile |
Change | Manage & control it (Hard to accommodate) | Change is inevitable |
Planning | Comprehensive up front design | Plan as you go |
Collaboration | Work alone | Work with Devs and BAs |
Hand Offs | Formal entrance and exit criteria | It’s not a relay race: collaborate |
Test Automation | System-level, built by tool specialists, created after the code is “done” | All levels, built by everyone, an integral part of the project |
Web Automation - Is as simple as?
I have worked on various tools for web automation so far, and I see web automation as a simple mechanism if we break them in to generic actions (Be it any tool/Language).
I would call them Four basic and only pillars.
1) Click - Button, Link, Image
2) Select Drop down, option, radio etc
3) Navigate URL
4) Verify Text (On a page, in a Textbox, in a Table, in a Div , page title)
I would call them Four basic and only pillars.
1) Click - Button, Link, Image
2) Select Drop down, option, radio etc
3) Navigate URL
4) Verify Text (On a page, in a Textbox, in a Table, in a Div , page title)
Mumbai Attacks
ऐ दिल हैं मुश्किल जीना यहाँ
ज़रा हट के ज़रा बच के
ये हैं मुंबई मेरी जान
Means :
This is really difficult to Live in Mumbai.
Be careful
This is my Mumbai
Rightly said and it has become increasingly difficult to Live here. Thanks to "resilient" Indian nature (At least that's what we are called by these politicians).
"Enough is Enough" is the say of the moment and rightly so, we can not keep being mum and letting these politicians play their vote politics.
People who came on the Boat can be caught, what do we do with these people who came by "Vote".
"We have proof who these terrorist were", then what are we waiting for, Another attack? I think they lack will power. We definitely don't lack the courage and military power.
Last few months Mumbai was busy beating Biharis and Bhaiyas. Police was proud of killing Rahul raj (Bihari Youth), same Mumbai police was seen (Not all of them) running around in CST station when these terrorists strike. Mr. Raj thackrey was busy making his vote bank, being "Aamchi Mumbai" well wisher. And on top of that congress was buys proving "Hindu Terrorism" (If at all that exists).
Mr Thackrey, Please wake up now and think beyond the politics; At least for your "Aamchi Mumbai".
And I sincerely appeal to Mr Amar Singh to sponsor a advocate for one the live terrorist so that he can add few more votes to his kitty.
Mr Amitabh bachhan, if you have lost your sleep in Mumbai then I think you should have really commended Mr Amar Singh's act of questioning the Batla house encounter. Don't worry Sir, you will be safe, Lets us worry about common man.
At last I really salute the Army, NSG and Police who did a commendable job fighting the situation out.
Jai hind.
ज़रा हट के ज़रा बच के
ये हैं मुंबई मेरी जान
Means :
This is really difficult to Live in Mumbai.
Be careful
This is my Mumbai
Rightly said and it has become increasingly difficult to Live here. Thanks to "resilient" Indian nature (At least that's what we are called by these politicians).
"Enough is Enough" is the say of the moment and rightly so, we can not keep being mum and letting these politicians play their vote politics.
People who came on the Boat can be caught, what do we do with these people who came by "Vote".
"We have proof who these terrorist were", then what are we waiting for, Another attack? I think they lack will power. We definitely don't lack the courage and military power.
Last few months Mumbai was busy beating Biharis and Bhaiyas. Police was proud of killing Rahul raj (Bihari Youth), same Mumbai police was seen (Not all of them) running around in CST station when these terrorists strike. Mr. Raj thackrey was busy making his vote bank, being "Aamchi Mumbai" well wisher. And on top of that congress was buys proving "Hindu Terrorism" (If at all that exists).
Mr Thackrey, Please wake up now and think beyond the politics; At least for your "Aamchi Mumbai".
And I sincerely appeal to Mr Amar Singh to sponsor a advocate for one the live terrorist so that he can add few more votes to his kitty.
Mr Amitabh bachhan, if you have lost your sleep in Mumbai then I think you should have really commended Mr Amar Singh's act of questioning the Batla house encounter. Don't worry Sir, you will be safe, Lets us worry about common man.
At last I really salute the Army, NSG and Police who did a commendable job fighting the situation out.
Jai hind.
QTP for Agile acceptance testing
It may sound crazy..but its possible.
What if you have already got QTP Licenses and you want to use that for Automated acceptance testing.
There is no second doubt that QTP is a very robust and easy to use, and uses standard VBScript for the scripts.
QTP support launching of the Testsuite using commoand line and may very well be used for cruise integration, obviously not for regular builds. However, using QTP for nightlt build is not a bad idea at all.
I have tried it once in a project and it works well.
What if you have already got QTP Licenses and you want to use that for Automated acceptance testing.
There is no second doubt that QTP is a very robust and easy to use, and uses standard VBScript for the scripts.
QTP support launching of the Testsuite using commoand line and may very well be used for cruise integration, obviously not for regular builds. However, using QTP for nightlt build is not a bad idea at all.
I have tried it once in a project and it works well.
Subscribe to:
Posts (Atom)