![](/img/trans.png)
[英]Java + Selenium + Chromedriver on win. Server 2012 R2
[英]Selenium automation test on Windows Server 2012 R2 using local host
我正在嘗試在使用Windows Server 2012 R2的Amazon active Workspace上開發自動化測試。 我正在使用localhost:8002
在本地計算機上執行此操作。 機器上沒有互聯網。 到目前為止,我有以下代碼:
package activeworkspaceprog;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class ActiveWorkspaceProg {
WebDriver driver;
JavascriptExecutor jse;
public static void main(String[] args)
{
ActiveWorkspaceProg run = new ActiveWorkspaceProg();
run.invokeBrowser();
}
public void invokeBrowser()
{
try
{
System.setProperty("webdriver.ie.driver","C:\\Users\\Administrator\\Desktop\\IEDriverServer.exe");
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
driver = new RemoteWebDriver(
new URL("https://WIN-K0E8GV2L510:8002@hub-cloud.browserstack.com/wd/hub")
,capability);
capability.setCapability(InternetExplorerDriver.
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.get("http://localhost:8002/awc/");
}
catch( Exception e)
{
e.printStackTrace();
}
}
}
I am using Selenium Standalone Server-3.13.0 jar and IEDriverServer.exe (version - 3.13.0.0) as my WebDriver.
But, I am just getting the following error,and I am stuck.
錯誤:
org.openqa.selenium.remote.UnreachableBrowserException:無法啟動新的會話。 可能的原因是遠程服務器的地址無效或瀏覽器啟動失敗。 構建信息:版本:'3.13.0',版本:'2f0d292',時間:'2018-06-25T15:32:19.891Z'系統信息:主機:'WIN-K0E8GV2L510',ip:'10 .0.1.252', os.name:'Windows Server 2012 R2',os.arch:'amd64',os.version:'6.3',java.version:'1.8.0_171'
任何幫助,將不勝感激。
只是為了更新我的問題。 通過將Internet Explorer的安全設置設置為相同級別,我能夠解決此問題。 默認情況下,所有區域安全性均設置為不同級別。 Internet,本地Intranet和受限站點均啟用了保護模式。 但是,未為受信任的站點啟用它。 因此,這些不同級別的安全性設置會使瀏覽器感到困惑,最終會引發錯誤。 因此,請確保為所有人啟用或禁用它們,以便將它們設置在同一級別。 只需執行以下代碼即可調用瀏覽器:
WebDriver driver;
JavascriptExecutor jse;
public static void main(String[] args)
{
ActiveWorkspaceProg run = new ActiveWorkspaceProg();
run.invokeBrowser();
}
public void invokeBrowser()
{
try
{
System.setProperty("webdriver.ie.driver","C:\\Users\\Administrator\\Desktop\\IEDriverServer.exe");
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability("ignoreZoomSetting", true);
capability.setCapability(InternetExplorerDriver.
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.get("http://localhost:8002/awc/");
}
catch( Exception e)
{
e.printStackTrace();
}
}
}
查看以下鏈接以進一步了解
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.