JAVA+SELENIUM+TESTNG Building Automation Test Architecture (1) separation of code and data

Source: Internet
Author: User
Tags testng

1. Introduce the JAVA+SELENIUM+POM Automatic test framework, the first to realize the separation of code and account URL and other information. The 2nd supports cross-browser implementation by reading the configuration file.

1) Add information such as account URL to the properties file and read

2) write the browser class by fetching the configuration file to achieve browser switching

3) Test Browser class

Project structure:

1. Create a new folder place the properties file in the folder with the following contents:

# Browser Switcher
#browserName = Firefox
Browsername = Chrome
#browserName = IE
# test Server Switcher
Url=https://portal.rrx360.com
#URL =https://taobao.com

2. Write a method to parse the properties file class to read the file to get the required information

Package com.rrx.framework;

Import Java.io.FileInputStream;
Import java.io.IOException;
Import java.util.Properties;


public class Propertiesengine {
public static string GetProperties (string name) throws IOException {

Properties Properties=new properties ();
Properties.load (New FileInputStream (". \\TestConfig\\config.properties"));
String Zhi=properties.getproperty (name);

return zhi;

}
}

JAVA+SELENIUM+TESTNG Building Automation Test Architecture (1) separation of code and data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.