2017-05-17 2 views
0

간단한 Java Selenium 코드를 실행하려고했지만이 오류가 발생했습니다. 누구든지 알아낼 수 있습니까?Java Selenium 코드의 java.net.MalformedURLException

import org.openqa.selenium.*; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.chrome.ChromeDriver; 

public class test 
{ 
public static void main(String[] args) 
{ 
stem.setProperty("webdriver.chrome.driver","D:/apache-jmeter-3.1/bin/chromedriver.exe"); 
WebDriver driver = new ChromeDriver();  
driver.get("https://www.google.com/"); 
String Title = driver.getTitle(); 

//compare the actual title of the page with the expected one 
if (Title.contentEquals("Google")) 
{ 
System.out.println("Test Passed!"); 
} 
else 
{ 
System.out.println("Test Failed"); 
} 
driver.close(); 
} 

은}

+1

는 의미가 ** URL이 유효하지 않습니다 **. URL은 무엇입니까? –

+0

** driver.get ("http://google.com"); ** –

+0

@PrashanthNagendra로 링크를 전달했습니다. – DebanjanB

답변

0

당신이 get() 방법에 잘못된 URL을 사용하는 것 같다. get() 방법을 아래와 같이 사용해보십시오 : 코드에서

driver.get("http://www.google.com"); 

URL must contains "http://" or "https://" to define its protocol.

수정, 당신은 WebDriver Sampler 내부에 한 번 아래에 시도 할 수 있습니다 :

import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.chrome.ChromeDriver; 

public class test { 
    public static void main(String[] args) { 
    try{ 
    System.setProperty("webdriver.chrome.driver","D:/apache-jmet‌​er- 
     3.1/bin/chromedri‌​ver.exe"); 
    WebDriver driver = new ChromeDriver(); 
    driver.get("http://www.google.com"); 
    String Title = driver.getTitle(); 
    if (Title.contentEquals("Google")){ 
     System.out.println("Test Passed!"); 
    } else { 
     System.out.println("Test Failed"); 
    } 
    driver.close(); 
    } catch (Exception e){} 
} 

가}

+0

yea 나는 driver.get ("http://google.com")을 전달했습니다. –

+0

@PrashanthNagendra, WebDriver Sampler의 스크린 샷을 게시하십시오. –

+0

선생님, 코드를 시도했지만이 오류가 다시 발생했습니다 –

관련 문제