如何处理Selenium Java中的可重用组件?
示例
对于家长班。
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Baseclass {
public void login() throws IOException {
Properties prop = new Properties();
//Reading values from property file
FileInputStream ips = new FileInputStream(
"C:\\Users\\ghs6kor\\eclipse- workspace\\Inheritance\\config.properties");
prop.load(ips);
System.setProperty("webdriver.gecko.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get(prop.getProperty("url"));
}
}示例
对于儿童班。
import java.io.IOException;
public class Child extends Baseclass {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Child c = new Child();
c.login();
c.testinheritance();
}
public void testinheritance() {
// parent class method used in child class
login();
System.out.println("Test Inheritance");
}
}热门推荐
10 有趣赚钱祝福语简短英文
11 考试毕业祝福语老师简短
12 烟草客户新年祝福语简短
13 搬家祝福语卡片文案简短
14 订婚红包吉利祝福语简短
15 中考花束祝福语霸气简短
16 如何回应老师祝福语简短
17 离别对同事祝福语简短
18 上班祝福语简短文案