Selenium Webdriver无法打开Chrome中的网址[关闭]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 days ago. Improve this question I have problem with selenium webdriver. It only opens the chrome browser, but it not navigates to the url. Here is my code. import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Var { public static String webUrl = "https://www.google.com"; public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Driver\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("webUrl"); Thread.sleep(2000); } In console: java.lang.AssertionError at org.junit.Assert.fail(Assert.java:86) Any suggestions?


driver.get("webUrl"); THis will navigate to the url webUrl and not the content in the variable webUrl as its just a string you should call it as driver.get(webUrl); THis will refer to the varaible webUrl with content google.com

use http instead of https in webUrl string.

Just remove the double-quotes as webUrl is not String its a String reference variable driver.get("webUrl"); The below code is working fine driver.get(webUrl);