package ICICI;獲取異常log4j:WARN請正確初始化log4j系統
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
public class ICICI_CareerHomePage {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Starting Execution");
System.setProperty("webdriver.chrome.driver", "C://Users//Public//MessageCentre//InputFiles//chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
String useragent= "Mozilla/45.4.0 (Windows NT 6.1\\; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36 WFBTesting";
options.addArguments("--user-agent=" +useragent);
options.addArguments("--test-type");
options.addArguments("--allow-running-insecure-content");
options.addArguments("disable-infobars");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
//driver.additional.capabilities={"chromeOptions":{"args":["--user-agent=Mozilla/5.0 (Windows NT 6.1\\; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 WFBTesting"]}};
WebDriver driver = new ChromeDriver(capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.com/");
System.out.println("ICICI Home Page Opened");
}
}
我寫上面的代碼,但它拋出異常爲:
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
您遇到的異常與實際錯誤沒有關係。如果仔細觀察,您應該嘗試解決的錯誤是「線程中的異常」主「org.openqa.selenium.remote.UnreachableBrowserException:與遠程瀏覽器通信時出錯。它可能已經過世。# –
@Amreeta您能否使用您正在使用的Selenium,ChromeDriver和Google Chrome版本更新我們 – DebanjanB