0

This is my URL in object repository file

URL = https://www.google.co.in/

And this is my code

WebDriver driver = new FirefoxDriver();
 driver.get("URL");

Getting error - Exception in thread "main" org.openqa.selenium.WebDriverException: Target URL URL is not well-formed. Command duration or timeout: 43 milliseconds

2
  • What is your object repository? How is it organized? How do you get items from it?
    – Alexey R.
    Commented Feb 3, 2018 at 20:23
  • what type of file are you using for a object repository is it .txt, .properties, .yml , .yaml, etc....
    – Alok
    Commented Feb 5, 2018 at 7:29

2 Answers 2

3

Selenium's driver.get method expects the argument to be a URL, not a string. What you've entered is a string which is why the error has occured.

Try

driver.get(URL);

or simply

driver.get("https://www.google.com");
2
  • Technically, the parameter to driver.get() is a string . . . it's just a matter of passing in the right string . . . .
    – ernie
    Commented Feb 4, 2018 at 3:28
  • He is trying to get the url that is stored on the object repository file. since he is trying to read a value from a file. I don't think he can directly call the url variable.
    – Alok
    Commented Feb 5, 2018 at 12:44
0

In repository...URL is already defined as String...so just use URL without quote...e.g.

WebDriver driver = new FirefoxDriver();
driver.get(URL);

If error didn't resolve through this...try

WebDriver driver = new FirefoxDriver();
System.out.print(URL);
//driver.get(URL);

Verify whether URL contains the proper url which you have defined in object repository. Hoping this should resolve your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.