package trails2110;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo01 {
WebDriver driver;
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "D:\\Eclipse\\Drivers\\chromedriver.exe");
System.out.println("1");
driver= new ChromeDriver();
System.out.println("2");
}
@After
public void tearDown() throws Exception {
driver.close();
}
@Test
public void test() {
String url= "www.hotstar.com";
System.out.println("3");
driver.get(url);
System.out.println("4");
String Title=driver.getTitle();
System.out.println(Title);
}
}
In Console till 3 its getting printed. I have latest version of chrome and latest version of chrome driver for it. i tried with multiple drivers didnt work. am i missing something?
I am able to route to the url with the following code
System.setProperty("webdriver.chrome.driver", "D:\\Eclipse\\Drivers\\chromedriver.exe");
WebDriver driver= new ChromeDriver();
String url = "https://www.google.com";
String script = "window.location = \'" url "\'";
((JavascriptExecutor) driver).executeScript(script);
any reasons its not happening with get() method and happening with JavascriptExecutor ?
CodePudding user response:
You should declare the URL with its protocol. So
String url= "www.hotstar.com";
url = "https://" url