Saifur
Saifur

Reputation: 16201

How to perform feasible web smoke test with Selenium WebDriver?

I have been doing some research on feasible and faster web page loading test with Selenium. A general idea of smoke testing is to click and navigate through the whole site to make sure the pages load properly. I was initially thinking to use some kind of ways to capture the http status code through some kind of http libraries since Selenium does not have any native support for that. But, I found it is not what I want since it will simply return Each and Every links of the site and most of them will be the ones I do not want. So the best way will be to perform actual click and take pages in return. The problem there is the execution time it will take. However, that’s what I am doing currently. Splitting the whole application into different modules and click through all VISIBLE links and take page objects in return with known selector. I am using FindElements() method to grab all the links of a page and click back and forth to test page load. I am doing something like the following:

Is there a better way to improve the performance?

WebElement deliveredChartDailyFocus = driver.findElement(By.id("delivered-chart-daily"));
deliveredChartDailyFocus.click();

// Get a list of all the <rect> elements under the #delivered-chart-daily element
List<WebElement> children = deliveredChartDailyFocus.findElements(By.tagName("rect"));

WebElement elementToClick = null; // variable for the element we want to click on
for (WebElement we : children)    // loop through all our <rect> elements
{
    if (we.isDisplayed())
    {
        elementToClick = we;      // save the <rect> element to our variable
        break;                    // stop iterating
    }
}

if (elementToClick != null)       // check we have a visible <rect> element
{
    elementToClick.click();
}
else
{
    // Handle case if no displayed rect elements were found
}

Upvotes: 3

Views: 1222

Answers (1)

olyv
olyv

Reputation: 3817

I would never call process of verification of every single link 'smoke testing'. For example how ISTQB defines this "A subset of all defined/planned test cases that cover the main functionality of a component or system, to ascertaining that the most crucial functions of a program work, but not bothering with finer details". And ths actually mean to exacute some meaningful scenarios and check some small flow/piece of functionality. Only clicking every link will check correctness of links but not computations or logic performed by server side. As for improving speed of passing tests you can consider running tests in parallel.

Upvotes: 1

Related Questions