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