Пожалуйста, сообщите, что оператор print не работает после метода (логина) в TestNG. Он отлично печатает инструкцию метода входа.
package lectures;
import java.io.IOException;
public class DependencyAnnot extends TestBase {
// the code is written to check the inheritancce which helps us from hardcoding
// the values
public void OpenBrowser() throws IOException, InterruptedException {
System.out.println("executing the browser opening");
login();
}
}
метод входа был унаследован от класса "TestBase", код которого выглядит следующим образом
public class TestBase {
//System.setProperty("webdriver.chrome.driver","D:\\bharath\\Selenium\\chromedriver.exe");
public WebDriver driver = null;
@Test
public void login() throws IOException {
Properties prop = new Properties();
// properies class is used to scan and fileinput stream gives us location to scan
FileInputStream fis = new FileInputStream("D:\\raj\\src\\lectures\\datadriven.properties");
prop.load(fis);
System.out.println(prop.getProperty("username"));
System.out.println("opening browser");
// instead of hard-coding the browser we are using datadriver folder to help us
// choose the correct browser
if (prop.getProperty("browser").contains("chrome"))// if the datadriven.properties file has browser = chrome use
// it else its firefox
{
driver = new ChromeDriver();
// a webdriver defined in if statemetn is only valid in that if statemeent so
// its better to define after class
} else {
driver = new FirefoxDriver();
}
driver.get(prop.getProperty("url"));
System.out.println("closing browser");
}