Grid 平台歷史

關於在 Grid 2 中使用平台名稱的資訊。

此文件先前位於 wiki
您可以閱讀更多關於 Grid 2 的資訊

Selenium Grid 平台

本節描述用於配置 Selenium Grid 節點和 [DesiredCapabilities] 物件的 PLATFORM 選項。

平台歷史

當從 Grid 請求新的 WebDriver 會話時,使用者可以指定遠端瀏覽器的 [DesiredCapabilities]。 諸如瀏覽器名稱、版本和平台之類的事項是可以由測試指定的選項列表中的一部分。 指定期望的。

以下程式碼示範了 Windows XP 平台上 Internet Explorer 版本 9 的 DesiredCapability

	[[DesiredCapabilities]] capability = DesiredCapabilities.internetExplorer();
	capability.setVersion("8");
	capability.setPlatform(Platform.XP);
	WebDriver driver = new RemoteWebDriver(new URL("https://#:4444/wd/hub"), capability);

對具有指定 DesiredCapability 的新會話的請求被發送到 Grid Hub,它將檢查所有已註冊的節點,以查看是否有任何節點符合測試給出的規範。 如果沒有節點符合規範,將返回 CapabilityNotPresentOnTheGridException。

一個常見的誤解是 PLATFORM 決定了選擇將在其上建立新會話的作業系統的能力。 在這種情況下,平台和作業系統並不相同,因此將平台指定為“Windows 2003 Server” 並不能讓您在 Windows XP、Vista 和 2003 Server 之間進行選擇。 這種誤解可能源於 Mac OSX 和 Linux 等平台,其中平台的名稱與作業系統的名稱相符。

在 Selenium Grid 的情況下,平台指的是 Driver Atoms 和 Web 瀏覽器之間底層的互動。 基於 Mac OSX 和 Linux 的作業系統(Centos、Ubuntu、Debian 等)與 Firefox 和 Chrome 等 Web 瀏覽器具有相對穩定的通訊。 因此,平台名稱很容易理解,如下例所示

   capability.setPlatform(Platform.MAC);   //Set platform to OSX
   capability.setPlatform(Platform.LINUX); // Set platform to Linux based systems

在 Vista 發布之前,基於 Windows 的作業系統只有一個平台,如下所示

	capability.setPlatform(Platform.WINDOWS); //Set platform to Windows

然而,隨著 Windows Vista 中 UAC 的引入,WebDriver 和 Internet Explorer 之間的底層互動發生了重大變化。 為了解決 UAC 約束,為具有基於 Windows 的作業系統的節點添加了一個新平台

	capability.setPlatform(Platform.VISTA); //Set platform to VISTA

隨著 Windows 8 的發布,WebDriver 與 Internet Explorer 的通訊方式再次發生重大變革,因此為基於 Windows 8 的節點添加了一個新平台

	capability.setPlatform(Platform.WIN8); //Set platform to Windows 8

Windows 8.1 的引入也發生了類似的故事,在此範例中,平台設定為 Windows 8.1

	capability.setPlatform(Platform.WIN8_1); //Set platform to Windows 8.1

作業系統平台

以下列表示範了一些作業系統,以及它們所屬的平台

MAC 所有 OSX 作業系統 LINUX Centos Ubuntu UNIX Solaris BSD XP Windows Server 2003 Windows XP Windows NT VISTA Windows Vista Windows 2008 Server Windows 7 WIN8 Windows 2012 Server Windows 8 WIN8_1 Windows 8.1

系列

不同的平台被分組到平台的「系列」中。 例如,Win8 和 XP 平台是 WINDOWS 系列的一部分。 同樣,ANDROID 和 LINUX 是 UNIX 系列的一部分。

選擇平台和平台系列

在 [DesiredCapabilities] 物件上設定平台時,我們可以設定單個平台或平台系列。 例如

  	capability.setPlatform(Platform.VISTA); //Will return a node with Windows Vista or 2008 Server or Windows 7 Operating System.
  	capability.setPlatform(Platform.XP);   //Will return a node with Windows XP or 2003 Server or Windows 2000 Professional Operating System.   
  	capability.setPlatform(Platform.WINDOWS); //Will return a node with ANY Windows Operating System

更多資訊

有關最新平台的更多資訊,請查看此檔案

org.openqa.selenium.Platform.java

上次修改時間 2022 年 1 月 10 日:更多 wiki (#907) [部署網站] (adcf706a1ad)