Спасибо! Кстати, разобрался с проблемой в драйвере после return.
Теперь ругается на подключение этого файла с параметрами. Драйвер стартует, запускает страницу, прописанную в этом properties - и падает. java.io.FileNotFoundException.
код в студию ВЕСЬ! и положить файл в ту же папку где файл с классом
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Properties;
public class Auth {
public static WebDriver driver;
public static String getDataProperties(String param) throws Exception {
Properties props = new Properties();
props.load(new InputStreamReader(new FileInputStream("testing.properties"), "UTF-8"));
return props.getProperty(param);
}
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver(new FirefoxProfile(new java.io.File("C://EDI3//develop//src//forTestingB2B")));
}
@Test
public void auth() throws Exception {
driver.get(getDataProperties("PageOpen"));
driver.findElement(By.linkText("Вход по паролю")).click();
driver.findElement(By.id("login")).click();
driver.findElement(By.id("login")).clear();
driver.findElement(By.id("login")).sendKeys("lebedev");
driver.findElement(By.name("password")).click();
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("111111");
driver.findElement(By.id("btn-login")).click();
}
public WebDriver getDriver() {
return driver;
}
}
Файл положил туда.
можно еще скрин самого файла
class DataProperties {
protected static Properties PROPERTIES;
static {
PROPERTIES = new Properties();
URL props = ClassLoader.getSystemResource("файл");
try {
PROPERTIES.load(props.openStream());
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getProperty(String key) {
return PROPERTIES.getProperty(key);
}
}
Вот этой класс пробуйте
driver.get(DataProperties.getProperty(“PageOpen”));
и текст. файл должен быть в одной папке (пакете) где и этот класс!
отельный файл можно
вылезает ошибка на первом обращении - driver.get(DataProperties.getProperty("PageOpen"));
java.lang.ExceptionInitalizerError
Caused by: java.lang.NullPointerException