java - Webdriver throwing "Cannot navigate to invalid URL" error -
webdriver able navigate base url unable perform actions in clicking link or getting page title. the:
driver.getcurrenturl()
is throwing:
unhandled inspector error: {"code":-32603,"message":"cannot navigate invalid url"
not sure how fix it.
can check if have prepended http in url. think solve issue in case did not use it.
change navigate part as:
driver.navigate().to("http://www.example.com");
in second ex too, use following:
driver.navigate().to("http://www.url.com/"); driver.findelement(by.linktext("login").click();
complete source code:
import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.chrome.chromedriver; import org.openqa.selenium.safari.safaridriver; public class checkwebdriver { private final webdriver driver = new safaridriver(); void checklogin(){ string baseurl = "http://newtours.demoaut.com/"; driver.get(baseurl); system.out.println(driver.getcurrenturl()); driver.findelement(by.linktext("register")).click(); } public static void main(string[] args) { checkwebdriver web = new checkwebdriver(); web.checklogin(); } }
Comments
Post a Comment