如何使用Selenium WebDriver执行可行的网络烟雾测试? [英] How to perform feasible web smoke test with Selenium WebDriver?

查看:92
本文介绍了如何使用Selenium WebDriver执行可行的网络烟雾测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究使用Selenium进行可行且更快的网页加载测试.冒烟测试的一般想法是单击并浏览整个站点,以确保页面正确加载.我最初考虑使用某种方式通过某种http库捕获http状态代码,因为Selenium对此没有任何本机支持.但是,我发现这不是我想要的,因为它只会返回网站的每个"链接,而大多数链接都是我不想要的链接.因此,最好的方法是执行实际的点击并获取页面作为回报.问题在于执行时间很长.但是,这就是我目前正在做的事情.将整个应用程序拆分为不同的模块,然后单击所有可见链接,并使用已知的选择器作为返回的页面对象.我正在使用FindElements()方法来获取页面的所有链接,然后来回单击以测试页面加载.我正在执行以下操作:

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:

是否有更好的方法来提高性能?

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
}

推荐答案

我永远不会将每个链接的验证过程称为烟雾测试".例如, ISTQB 如何定义此所有已定义/计划的测试的子集涉及组件或系统主要功能的案例,以确定程序的最关键功能起作用,但不打扰更精细的细节."实际上,这意味着执行一些有意义的方案并检查一些小流程/功能.仅单击每个链接将检查链接的正确性,但不会检查服务器端执行的计算或逻辑.为了提高通过测试的速度,您可以考虑并行运行测试.

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.

这篇关于如何使用Selenium WebDriver执行可行的网络烟雾测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆