I'm creating a new test project and can't think of anything else to try to resolve my issue. I have another Selenium project that works as expected, and have compared the two to find differences. But first, the main issue I'm running into. In the setup I call Driver.Navigate().GoToUrl("www.test.com"); No exception is thrown or anything else that would indicate there is a problem, the flow just moves to the next statement, but no Url is entered into the navigation bar, and so obviously the driver never navigates to any page. The driver does start up a new firefox instance, but it stays blank.
When I compare this new project against an already working project, they seem identical for the most part. Both projects have ...\packages\Selenium.WebDriver.2.37.0 & ...\packages\Selenium.Support.2.37.0 installed using NuGet package manager. Both projects have identical references to the project in the .csproj file --Working project ... ....\packages\Selenium.WebDriver.2.37.0\lib\net40\WebDriver.dll False ....\packages\Selenium.Support.2.37.0\lib\net40\WebDriver.Support.dll
--Unworking project ... ..\packages\Selenium.WebDriver.2.37.0\lib\net40\WebDriver.dll ..\packages\Selenium.Support.2.37.0\lib\net40\WebDriver.Support.dll
Neither project does anything else. The constructor for both simply calls: var WebDriver = new FirefoxDriver();
When I examine the WebDriver object, the only difference I can see is the WindowsHandles property. The working project has: WindowsHandles Count = 1
The non-working project has: WindowsHandles {System.Collections.ObjectModel.ReadOnlyCollection}
I have no idea why they're different but as it's the only difference I can find, I'm thinking maybe that's the problem but I have no idea if that's really the case or how I'd fix it.
I've added a try/catch block around the WebDriver.Navigate().GoToUrl() and no exception is being caught.
Both projects target the .NET 4.0 framework.
Any help is greatly appropriated.
So the main difference between get() and navigate() is, both are performing the same task but with the use of navigate() you can move back() or forward() in your session's history. navigate() is faster than get() because navigate() does not wait for the page to load fully or completely.
Google's Answer: get() is used to navigate particular URL(website) and wait till page load. driver. navigate() is used to navigate to particular URL and does not wait to page load.
We can obtain the URL of the current page with Selenium webdriver. This is achieved with the help of getCurrentUrl() method. It fetches the URL of the opened application. This method accepts no parameters and strings the URL in the form of String.
I figured it out right after I finally broke down and decided to post on StackOverflow. My issue was IWebDrivers
insists upon a passed in URL beginning with http
. Once I prefixed my URL with that, it worked.
Here is a simple example how to do so:
Add NuGet package Selenium.WebDriver
Download chromedriver (https://sites.google.com/a/chromium.org/chromedriver/) or any other driver from http://www.seleniumhq.org/download/ (section Third Party Browser Drivers NOT DEVELOPED by seleniumhq)
Copy the file to your project directory in Visual Studio and set the following properties for the file:
Build Action = None; Copy to Output Directory = Copy if newer
Once installed, try running the following example code:
var driver = new ChromeDriver();
var navigate = driver.Navigate();
navigate.GoToUrl("http://www.microsoft.com"); //works
navigate.GoToUrl("www.microsoft.com"); //does not work
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With