My Recent Selenium WebDriver Posts from Medium.com

app business communication connection

Photo by PhotoMIX Ltd. on Pexels.com

 

I have been posting recently more on medium.com.

See below a list of the recent articles.

I hope that you find them useful.

Thanks.

 

How to Create Self Logging Selenium Tests

There are a few options here.

One is using the EventFiringDriver class from the Selenium WebDriver API.

The other is about creating custom element classes for each type of element.

 

How Would I Convert Myself from Manual Tester to Test Automation Engineer?

Someone asked me this intriguing question after a recent meetup.

So I started thinking about I would do it.

 

What Test Automation Skills Will Be In Demand in 5 Years?

What should a manual tester learn to have a good and long automation career?

Which skills are better for the long run?

 

Selenium WebDriver Interview Questions

  1. Why should a company implement test automation at all?
  2. Describe page object model.
  3. What are all different ways of finding an element using Selenium WebDriver?
  4. How do you wait until the title and url of a page are both correct?
  5. After opening the home page of a site, a popup is displayed randomly. How do you handle this popup?

 

What Are Test Automation Good Practices?

Test automation is development so it follows all good practices for coding.

But it should follows also good test automation practices as well.

 

An SDET is a developer and not a tester

Test automation is a development discipline.

It is not a testing one.

 

How to Go from Manual Test to a Selenium Automated Test?

Step by step approach for decomposing a manual test case to a test case suitable for test automation.

 

 

 

View at Medium.com

One of the best ways of making your Selenium WebDriver scripts faster is to run them in parallel.

You can do this with the Maven SureFire plugin.

Maven SureFire has settings for running in parallel both methods and classes.

 

By default, Selenium WebDriver scripts are executed sequentially

I will use a sample project to explain how to run Selenium WebDriver scripts in parallel.

The sample project is created as a Maven project in Eclipse and it includes

  • one test script

 

 The POM.XML includes
  • plugin for Maven Compiler

 

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”&gt;

<modelVersion>4.0.0</modelVersion>

<groupId>com.siminiuc</groupId>

<artifactId>MavenProject</artifactId>

<version>0.0.1</version>

<name>Maven Project</name>

<url>http://maven.apache.org</url&gt;

<dependencies>
 
     <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.12</version>
         <scope>test</scope>
     </dependency>
 
     <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.47.1</version>
      </dependency>
 
</dependencies>
 
<build>
<plugins>
 
     <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-compiler-plugin</artifactId>
             <version>2.3.2</version>
             <configuration>
                      <fork>true</fork>
                      <source>1.7</source>
                      <target>1.7</target>
                      <executable>C:\JDK\bin\javac.exe</executable>
             </configuration>
        </plugin>
 
</plugins>
</build>
 
</project>

 


selenium free course

The test class includes 5 JUNIT test scripts, all of them having the same code:

 

import static org.junit.Assert.*;import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

 

public class TestClass1
{

 

WebDriver driver;
String siteUrl = “http://www.vpl.ca&#8221;;
String keyword = “java”;

 

@Before
public void setUp()  {
driver = new FirefoxDriver();
}

 

@After
public void tearDown() {
driver.quit();
}

 

@Test
public void testFirstResult() throws InterruptedException 
{
HomePage homePage = new HomePage(driver);
ResultsPage resultsPage =
homePage.open(siteUrl).typeKeyword(keyword).executeSearch();
DetailsPage detailsPage = resultsPage.selectResult(1);
assertTrue(detailsPage.visibilityBookTitle() == true);
assertTrue(detailsPage.lengthBookTitle() > 0);
assertTrue(detailsPage.visibilityBookAuthor() == true);
assertTrue(detailsPage.lengthBookAuthor() > 0);
}

 

@Test
public void testSecondResult() throws InterruptedException
{ ………..}

 

@Test
public void testThirdResult() throws InterruptedException
{ ………. }@Test
public void testFourthResult() throws InterruptedException
{ ……… }@Test
public void testFifthResult() throws InterruptedException
{ …….. }}The project is executed using the Maven Test command:

 

 

The JUNIT test scripts from the test class are executed sequentially.

The execution time is 1.44 minutes.

 

Run the JUNIT test scripts in parallel

A few changes are needed to the POM.XML file.

We need to add a new plugin for Maven Surefire.

For the Maven Surefire plugin, the following settings are required:

parallel = methods
threadCounts = 5

 

 

<modelVersion>4.0.0</modelVersion>
<groupId>com.siminiuc</groupId>
<artifactId>MavenProject</artifactId>
<version>0.0.1</version>
<name>Maven Project</name>
<dependencies>
 
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
                         <scope>test</scope>
                </dependency>
 
                <dependency>
                       <groupId>org.seleniumhq.selenium</groupId>
                       <artifactId>selenium-firefox-driver</artifactId>
                       <version>2.47.1</version>
                </dependency>
 
</dependencies>
 
<build>
 
<plugins>
 
              <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-compiler-plugin</artifactId>
                   <version>2.3.2</version>
                   <configuration>
                           <fork>true</fork>
                           <source>1.7</source>
                           <target>1.7</target>
                           <executable>C:\JDK\bin\javac.exe</executable>
                   </configuration>
            </plugin>
 
           <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <version>2.19</version>
                  <configuration>
                        <parallel>methods</parallel>
                        <ThreadCount>5</threadCount>
                  </configuration>
           </plugin>
 
</plugins>
</build>
 
</project>
 

Running the project again shows the JUNIT scripts running in parallel.

 

The execution time is 41 seconds.

 

 

The execution time was reduced with 60% through by running the scripts in parallel.


selenium free course

If you have any questions about this article, please leave them in the Comments section.

How was the Selenium name chosen?


Selenium was so named because Huggins, dissatisfied with testing tools on the market, was seeking a name that would position the product as an alternative to the QuickTest Professional commercial testing software built by a company called Mercury Interactive:

 

The name, Selenium, was selected because selenium mineral supplements serve as a cure for mercury poisoning, Huggins explained.




From techworld.com