问题
I get the following error :
unknown error: unhandled inspector error:
{"code":-32603,"message":"Cannot navigate to
invalid URL"} (Session info: chrome=29.0.1547.57) (Driver info:
chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64)
I think its got to do with chrome browser last updated version (29) about two days ago.
*Note:*my chromedriver is up to date (2.2).
please let me know what should i do to fix it.
回答1:
I received the same error while using Selenium on python. Prepending the destination url with http://
solved my problem:
self.driver.get("http://"+url.rstrip())
回答2:
This literally happens because the url you are passing in is using an invalid format.
Try the following debug code, where ourUrl
is the String of the URL you are trying to connect to:
System.out.println("!!URL " +ourUrl);
driver.get(ourUrl);
for me it was printing out: !!URL "http://www.salesforce.com" And the problem was that there were quotes around the url. In your case it may be something similar. Once you properly format the url, it will work
回答3:
If the error message is "invalid url", check the url on the webpage that you are trying to access, then compare it to what prints out when you do something like:
System.out.println(url);
When selenium tries to open up a webpage, it needs the exact url. It wont infer the Hyper Text Transfer Protocol (http:// or https://). In other words, if you try driver.get(url), and url is returning www.myurl.com, it will likely fail if http or https was not appended.
//Append the Hyper Text Transfer Protocol to the url
driver.get("http://" + url);
If you are getting your urls from a list, or from a file, and you know which protocol your website page(s) use (http:// or https://), you can do something like:
public static void getURLByDriverFromList(List<String> urls) {
for(List<String> url : urls) {
if(!url.contains("http://") {
url = "http://" + url;
}
driver.get(url);
}
}
回答4:
I met this error now minutes ago,but i have solved it by adding "https://" to the front of the url. Hope it works for you too.Good luck!
回答5:
You can use absolute path as mentioned in other comments or - if it is an internal link/button on the web - you can mapp it as WebElement
and perform click()
method.
回答6:
I had exactly the same error but it was due to a parsing issue in Python Behave BDD.
For example, if I have the following feature syntax
Given the user is on <page> using <url>
and my examples syntax has
Examples: Pages
| page | url |
| Mobile App using Guide | https://www.example.com |
See how I have the word using
between my variables in the given
statement and also used using
in the page title Mobile App using Guide
. Because of this, the word Guide
will get added on to the url and Selenium will return the invalid url error.
If you're using Behave or possibly any BDD with Gherkin syntax, avoid using the same keyword in between variables from the Given, When, Then statements in the Example table.
回答7:
Try the following code, it's working for me.
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com");
Add https
in your URL.
来源:https://stackoverflow.com/questions/18429680/selenium-error-cannot-navigate-to-invalid-url