Automation Testing Framework

2019-09-03 02:01发布

问题:

I am searching for UI Automation testing framework.

What we need is :

  1. The framework should provide record/playback option.
  2. It should be compatible with various browser and platforms.
  3. It should support all the the events click, Drag&Drop, mousehover etc nad some famous javascript libraries like D3js, Three.js(3D object events) etc.

and more important thing I want is

  • Suppose we have released 1st version of the application, in that application we have a login page with two fields e.g. Username and Password. We have recorded all possible test cases like around 200. Out of those 200 test cases suppose 50 test cases are starting with login event it means if i am changing in login page(adding/removing field) then those 50 test cases will get affected which are starting with login event.

Now in 2nd release i have decided to remove password field from the login page then the test cases which include login event will fail, because we have changed login scenario as I mentioned in above paragraph.

In this situation I want framework itself to alert or notify that if I make changes in login page (e.g. removing/Adding field) then some other test cases will affect which includes login event. At the same time the framework should give the flexibility to allow the tester to update the changes in all affected test cases automatically on one click.

Please suggest a Automation testing framework which will provide all this features.

回答1:

As an experinced automation specialist I would never recommend anyone to record test cases.

Test framework:
Interaction testing
If it is webbrowsers and black box testing that is you target, my suggestion is Selenium. It support the 3 major webbrowsers and more. It is easy you use and a lot of help on the web. It also is supported by several different languages, but my favorite is Java combined with TestNG.

Its not perfect when it comes to handle JS heavy webpages. Meaning pages which changes objects via JS will be harder to test with Selenium.This due to that selenium "downloads" the page uses the objects in downloaded DOM. If the DOM is changed Selenium will complain.

If it is to test functionality of the webpage objects such as field restrictions or if a button is enabled or not, Jasmine is quite fast and easy. Used more for unit testing the webpage.

Graphical Testing
If youre target is to verify how you output looks, you should turn to another framework. 3D.js Testing

For you test cases: My suggestions i you create a test harness for you webpage with helper classes. A helper class should contain common used flows, such as a login function. This allows you to only do the update in 1 place.

I also recommend that you create a class for each page with a function for each object you want to be able to reach. Now if you change the name or id for a button or field you only have 1 place which requires update, instead of every test case using the updated object.

Off course are there more frameworks then selenium, but from all investigations I have done and others i worked with, Selenium has been our choice.

I could write an essay about this, but this can get you started.



回答2:

You can use Page Object Model along with Selenium, as it will solve your purpose. As @andreas mentioned, you need to use helper classes which are moreover classes mapped to a webpage i.e. each webpage is mapped to one class.

Inside the class there will be an object (web elements ) identification mechanism code and related methods that will act on these elements.

I have one small snippet of code for demo purpose:

public class LoginPage
{

@FindBy(xpath="xpath-1")
private static WebElement userNameTxtBox;

@FindBy(xpath="xpath-2")
private static WebElement passwordTxtBox;

@FindBy(xpath="xpath-3")
private static WebElement loginBtn;

public void EnterUserName(String userName)
{
    EnterText(userNameTxtBox,userName);
}

public void EnterPassword(String password)
{
    EnterText(passwordTxtBox,password);
}

public void ClickOnLogin()
{
    ClickOnElement(loginBtn);
}
}

You can call these methods from your test code.

and in future if any object changes its ID, you can only change it here and your test class code will remain unaffected.

For complete reference how POM works, follow this link: http://www.guru99.com/page-object-model-pom-page-factory-in-selenium-ultimate-guide.html