Пытался создать файл свойств и получить информацию от него, но я получаю java.lang.NullPointerException, также попытался попробовать и поймать, поскольку я очень новичок в кодировании, может кто-нибудь, пожалуйста, дайте мне знать, почему вы получаете исключение нулевого указателя.Exception Selenium Webdriver TestNg
package ObjectRepository;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class PropertiesGuru99Bank {
WebDriver driver;
@Test
public void f() {
File file=new File("E:\\selenium\\Rahul\\Project\\src\\ObjectRepository\\object.properties");
FileInputStream f=null;
try {
f=new FileInputStream(file);
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getStackTrace());
}
Properties prop=new Properties();
try {
prop.load(f);
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getStackTrace());
}
driver.get(prop.getProperty("url"));
driver.findElement(By.id(prop.getProperty("id"))).sendKeys("rahul");
}
@BeforeTest
public void beforeTest() {
System.setProperty("webdriver.chrome.driver", "E:\\selenium\\lib\\chromedriver_win32\\chromedriver.exe");
new ChromeDriver();
}
@AfterTest
public void afterTest() {
}
}
Huhh .. wow thankyou somuch :) получил очищенный !! –
Да, конечно ... это сработало !!! :) –
вы также можете помочь мне с этим https://stackoverflow.com/questions/30137514/getting-tooltip-of-an-element-amazon-site .. :) @Saifur –