Posts

Write a script to open google.com and verify that title is Google and also verify that it is redirected to google.com

public class Test { public static void main(String[] args) { System.setProperty("webdriver.firefox.marionette","E:\\Selenium\\geckodriver-v0.23.0-win32\\geckodriver.exe"); WebDriver driver=new FirefoxDriver(); driver.get("https://www.google.com/"); String Title=driver.getTitle(); String getCurrentUrl = driver.getCurrentUrl(); if(Title.equalsIgnoreCase("google")) { System.out.println("Title is " + Title); } else { System.out.println(Title + "Title Not Matched"); } if (getCurrentUrl.contains("https://www.google.com/")) { System.out.println("The Current URL is  "+ getCurrentUrl); } else { System.out.println("The Current URL is not matched  "+ getCurrentUrl); } driver.close(); } }

org.openqa.selenium.firefox.NotConnectedException

1.  org.openqa.selenium.firefox.NotConnectedException This is the common Exception while Opening the Firefox through selenium To overcome this Problem we must have to use gecko driver and also if System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe");   // if above property is not working or not opening the application in browser then try below property              //System.setProperty("webdriver.firefox.marionette","G:\\Selenium\\Firefox driver\\geckodriver.exe"); import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Test1 {       public static void main(String[] args) {               System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe");                           // if above property is not working or not opening the application in browser then try below property