Selenium error - Cannot navigate to invalid URL - selenium

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.

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())

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

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!

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);
}
}

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.

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.

Try the following code, it's working for me.
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com");
Add https in your URL.

Related

Microsoft Bot Composer Send an HTTP request does not accept variable as Url input

Versions
Bot Composer version: 4.7.0-preview-191208-1
fresh project
yarn command triggered as in docs
Latest Chrome and Edge (chromium) stable version on Windows 10 Pro
Issue
The 'Send an HTTP request' Url field no longer seems to accept a variable as input for me. For example:
${getmyurl()}
The validation seems OK:
Where the getmyurl looks something like (it's not an escaping issue, I tried multiple values here with and without quotes etc...):
# getmyurl()
- just-a-test-string-to-see-if-this-throws-an-invalid-url-exception
The response in the 'Bot Framework Emulator' always gives the message:
BuildQnaAnwserUrl does not have an evaluator, it's not a built-in function or a custom function.
This used to work for me with an older version of the Composer (where the prefix was still an #). Is anyone else having this, is my syntax incorrect somehow?
You can save the Url in a variable at start of conversation. eg. Set a property -> user.Url : urlString. In http method Url field -> Pass it as ${user.Url}. The scope of variable can be defined as per requirement (user/conversation/dialog/turn)
Send an HTTP request

Jmeter Illegal character found in host: '/' ISSUE

I tried to install Jmeter on my colleague computer when I executed http request.He has been showing this error, but I found that there is no such error in my computer. I wonder if anyone has encountered a similar problem?
My
My1
My2
Colleague
colleague1
colleague2
--
error message
java.net.MalformedURLException: Illegal character found in host: '/'
at java.base/java.net.URL.<init>(URL.java:480)
at java.base/java.net.URL.<init>(URL.java:360)
at java.base/java.net.URL.<init>(URL.java:383)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getUrl(HTTPSamplerBase.java:1053)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
at java.base/java.lang.Thread.run(Thread.java:830)
This problem occurs when using the http request sampler, putting '/' at the end of the Server Name or Ip textbox. It will work if you delete the '/' character at the end of the host information and add it to path.
This www.amazon.com/ref=nav_logo is not a valid hostname
Valid characters for hostnames are ASCII(7) letters
from a to z, the digits from 0 to 9, and the hyphen (-). A hostname
may not start with a hyphen.
In any case your URL query string is not correct, it should look like:
https://www.amazon.com/?ref=nav_logo
^mind this character
So correct HTTP Request sampler configuration would be:
Resulting into the following request observable via View Results Tree listener
Going forward be aware that you can build a JMeter Test Plan using HTTP(S) Test Script Recorder or JMeter Chrome Extension
Even though I cannot tell you why the test behaves differently on your machine vs that of your colleaugue (I would guess that you probably chose different client implementations in the advanced section of the HTTP Request Sampler), you should definitely consider what part of your URL is:
Protocol
Server Name or IP
Path
Parameter
and use the corresponding fields in JMeter accordingly.
Hint: "/ref=nav_logo" is most definitely NOT part of the Server Name.
I faced this issue and it was for simple reason. in the server name/ip address instead giving only the severname/ip address i.e server1 i had accidentally included the https://server1 and spend two hours to resolve it

How can you include http://foo.local in CORS Access-Control-Allow-Origin?

I'm using *, but apparently that's not enough. I'm trying to upload a file from a client browser. It works when the client's URL is localhost:3000 or foo.com. It's not working when the URL is http://meteor.local. I've tried changing the third line to <AllowedOrigin>http://meteor.local</AllowedOrigin>, but get the same error.
The browser error:
The error text was misleading – error was not due to the header sent by s3. Adding an access rule to Cordova fixed it. (In meteor, add it with App.accessRule('http://meteor.local'); in mobile-config.js.)

403 : Access forbidden selenium

I want to run my testcases with the help of parameters mentioned in the testSuite.xml file and use them in my test cases by mentioning
#Parameters({ "selenium.host", "selenium.port", "selenium.browser", "selenium.url" }) in my code.
Though, I started a standalone server with -trustAllSSLcertificates, the system is giving "403 access forbidden error". However, if I run the test cases individually, by hardcoding the port, URL, Host & browsername, it works fine.
Where am i going wrong?.....
BTW, I run my test cases using build.xml file. Here also i added the -trustAllSSLcertificates when starting the server. But still it does not work.
Please help.
When running Selenium WebDriver using selenium-server-standalone I kept getting this error.
HTTP ERROR: 403
Forbidden for Proxy
RequestURI=/session
Turns out that it was because I needed to use the url http://localhost:4444/wd/hub as the url for the RemoteWebDriver client to connect to.
I'm sure there are a number of things that could cause the HTTP ERROR: 403, but you may want to double-check that it's resolving to the correct base url.

Don't stop on HTTP error 403

In one of my Selenium test cases, I try to ensure that certain pages can't be accessed. Instead, HTTP return code 403 should be given.
However, here Selenium terminates test execution with the following exception:
com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://user:password#www.example.com/admin Response_Code = 403 Error_Message = Forbidden
Any way to work around that?
Seems like I have to answer the question myself...
I now surround the "open" call with a try...catch block. There, I parse the exception message if it contains the 403 code and XHR ERROR. Seems to me not very clean, but it works.
I was trying to test for HTTP 403 errors using PHPUnit. I examined the PHPUnit Selenium Extension code and found that the driver ends the session as soon as it receives a bad response, and there does not appear to be a way to bypass this functionality.
I ended up using a try-catch solution and restarting the Selenium session:
try {
$this->open('restricted_url');
$this->assertTitle('The page cannot be displayed');
} catch (PHPUnit_Framework_Exception $e) {
$this->start();
}
When the Selenium session is restarted, all the session information is lost, as is to be expected, so you will need to build your session again in order to run more tests:
$this->loginAsGuest();
try {
$this->open('admin_url');
$this->assertTitle('The page cannot be displayed');
} catch (PHPUnit_Framework_Exception $e) {
$this->start();
$this->loginAsGuest();
}
I don't know what language you're using, but I think you can get around this by instructing Selenium to ignore the status code when opening a page.
In Ruby:
#browser.remote_control_command('open', [url, 'true'])
In C#:
((DefaultSelenium)selenium).Processor.DoCommand("open", new string[]{url, "true"}))
I believe the behavior in Selenium trunk is to now ignore the status code by default. So, you could try building that and see if it works out for you.