Where should I add the following statement
System.setProperty("webdriver.gecko.driver","//home//tuser//software//selenium//gecko_driver//geckodriver");
so that my code does not produce an error
public class class1 {
public static String baseURL = "https://facebook.com/";
public WebDriver driver = new FirefoxDriver();
@Test(priority = 1)
public void login() throws InterruptedException {
driver.get(baseURL);
driver.manage().window().maximize();
driver.findElement(By.id("username")).sendKeys("srikanth");
driver.findElement(By.id("password")).sendKeys("sri");
driver.findElement(By.id("login_button")).click();
Thread.sleep(30000);
}
I have used the answer provided by Jainish, but it didn't worked for me. For the same, I found out the following resolution:
I have modified the code written by Jainish. In the modified code, you can see that objects are declared with public scope outside any method, hence, allowing us to use this object anywhere within class1.
Also, there is no need to use static wait (which is Thread.sleep) and at implicit wait at the same time. Instead use Explicit wait to increase the script performance.
Hope, the above is useful. Please let me know if I am wrong anywhere.