- Selenium - Grid
- Selenium - TestNG
- Selenium - Test Design Techniques
- Selenium - User Interactions
- Selenium - Locators
- Selenium - WebDriver
- Selenium - Selenese Commands
- Selenium - Remote Control
- Selenium - Environment Setup
- Selenium - IDE
- Selenium - Overview
- Selenium - Home
Selenium Useful Resources
- Selenium - Discussion
- Selenium - Automation Practice
- Selenium - Useful Resources
- Selenium - Quick Guide
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Selenium - Grid
氯胺醇是一种工具,通过多种物理或虚拟机器传播测试,以便我们能够同时(同时)执行文字。 它通过向我们提供迅速和准确的反馈,大大加快了各行凶者和平台之间的测试过程。
Selenium Grid允许我们同时进行多种网络驱动器或Selenium遥控检测,同时使用相同的代码基数,因此该代码需要在其所实施的系统中出现NOT。 se-服务器独立包包括湖、网络驱动器和Selenium RC,以实施电网的文字。
Selenium Grid有一个枢纽和一个 No。
<Node-Nodes是湖中负责执行测试的ium。 一个或一个以上的节点可以由任何顾问组成,并可包含任何支持的浏览器。
Architecture
以下图表显示了Selenium Grid的结构。
Working with Grid
为了与格里德合作,我们需要遵循某些议定书。 下文列出参与这一进程的主要步骤——
Configuring the Hub
Configuring the Nodes
Develop the Script and Prepare the XML File
Test Execution
Result Analysis
让我们详细讨论这些步骤。
Configuring the Hub
Step 2——利用以下指挥发射Selenium服务器,从湖开始。 现在,我们将利用4444号港口开始该枢纽。
Step 3——现在开放浏览器和浏览器进入URL http/ localhost:444444 from the Hub (The system where 你已执行第2步)。 Step 4——现在点击了Cesole链接,点击电汇。 该中心的配置如下。 时至现在,我们没有任何节点,因此我们无法看到细节。 如果有, D:JARselenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine) http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub browserName = firefox (Parameter to specify the Browser name on Nodes) 5555 = Port on which Firefox Node would be up and running. Step 3——在指挥执行后,返回湖区。 纳维特里-URL-http://10.30.217.157:44 而湖现在将展示其附属的节点。 Step 4——现在让我们发射因特网探索者Node。 为了启动国际电子数据交换台,我们需要将因特网探索者驾驶员下载到点末机上。 如果有, D:IEDriverServer.exe = The location of the downloaded the IE Driver(on the Node Machine) D:JARselenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine) http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub browserName = ie (Parameter to specify the Browser name on Nodes) 5558 = Port on which IE Node would be up and running. Step 7——执行指挥后,返回湖区。 纳维特里-URL-http://10.30.217.157:44 湖现在将展示附属于它的伊埃诺德。 <Step 10——根据你的职业介绍所的类型下载驾驶员。 我们将在视窗环境中执行,因此我们将下载视窗 Chrome司机。 在你下载后,将前案卷解冻,并把它放在发射小.时必须提及的夹中。 Step 11——利用以下指挥发射 Chrome。 如果有, D:chromedriver.exe = The location of the downloaded the chrome Driver(on the Node Machine) D:JARselenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine) http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub browserName = chrome (Parameter to specify the Browser name on Nodes) 5557 = Port on which chrome Node would be up and running. Step 12——在指挥执行后,返回湖区。 纳维特里-URL-http://10.30.217.157:44 湖现在将展示其附属的神hr。 Browser 参数将从“XML”档案中删除。 Step 5——测试Ng.XML是根据项目夹创建的,如下所示。 Step 1——选择创建的XML;右翼和选择Rong As >> 测试NG Suite。 Step 1——在完成执行时,我们可以分析结果,如任何其他执行。 定本摘要载于下文摘要。 <2>Step 2-Nagate to the Results of Running Suite Tab and TestNG将显示以下结果摘要。 Step 3——在生成超文本时,我们将能够以超文本格式看到测试结果。
java -jar selenium-server-standalone-2.25.0.jar -port 4444 -role hub -nodeTimeout 1000
Configuring the Nodes
java -jar D:JARselenium-server-standalone-2.42.2.jar
-role node -hub http://10.30.217.157:4444/grid/register
-browser browserName = firefox -port 5555
C:>java -Dwebdriver.ie.driver = D:IEDriverServer.exe
-jar D:JARselenium-server-standalone-2.42.2.jar
-role webdriver -hub http://10.30.217.157:4444/grid/register
-browser browserName = ie,platform = WINDOWS -port 5558
C:>java -Dwebdriver.chrome.driver = D:chromedriver.exe
-jar D:JARselenium-server-standalone-2.42.2.jar
-role webdriver -hub http://10.30.217.157:4444/grid/register
-browser browserName = chrome, platform = WINDOWS -port 5557
Develop the Script and Prepare the XML File
package TestNG;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabipties;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import java.net.MalformedURLException;
pubpc class TestNGClass {
pubpc WebDriver driver;
pubpc String URL, Node;
protected ThreadLocal<RemoteWebDriver> threadDriver = null;
@Parameters("browser")
@BeforeTest
pubpc void launchapp(String browser) throws MalformedURLException {
String URL = "http://www.calculator.net";
if (browser.equalsIgnoreCase("firefox")) {
System.out.println(" Executing on FireFox");
String Node = "http://10.112.66.52:5555/wd/hub";
DesiredCapabipties cap = DesiredCapabipties.firefox();
cap.setBrowserName("firefox");
driver = new RemoteWebDriver(new URL(Node), cap);
// Puts an Imppcit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().imppcitlyWait(10, TimeUnit.SECONDS);
// Launch website
driver.navigate().to(URL);
driver.manage().window().maximize();
} else if (browser.equalsIgnoreCase("chrome")) {
System.out.println(" Executing on CHROME");
DesiredCapabipties cap = DesiredCapabipties.chrome();
cap.setBrowserName("chrome");
String Node = "http://10.112.66.52:5557/wd/hub";
driver = new RemoteWebDriver(new URL(Node), cap);
driver.manage().timeouts().imppcitlyWait(10, TimeUnit.SECONDS);
// Launch website
driver.navigate().to(URL);
driver.manage().window().maximize();
} else if (browser.equalsIgnoreCase("ie")) {
System.out.println(" Executing on IE");
DesiredCapabipties cap = DesiredCapabipties.chrome();
cap.setBrowserName("ie");
String Node = "http://10.112.66.52:5558/wd/hub";
driver = new RemoteWebDriver(new URL(Node), cap);
driver.manage().timeouts().imppcitlyWait(10, TimeUnit.SECONDS);
// Launch website
driver.navigate().to(URL);
driver.manage().window().maximize();
} else {
throw new IllegalArgumentException("The Browser Type is Undefined");
}
}
@Test
pubpc void calculatepercent() {
// Cpck on Math Calculators
driver.findElement(By.xpath(".//*[@id = menu ]/span[3]/a")).cpck();
// Cpck on Percent Calculators
driver.findElement(By.xpath(".//*[@id = menu ]/span[4]/span[3]/a")).cpck();
// Enter value 10 in the first number of the percent Calculator
driver.findElement(By.id("cpar1")).sendKeys("10");
// Enter value 50 in the second number of the percent Calculator
driver.findElement(By.id("cpar2")).sendKeys("50");
// Cpck Calculate Button
// driver.findElement(By.xpath(".//*[@id = content ]/table/tbody/tr/td[2]/input")).cpck();
// Get the Result Text based on its xpath
String result =
driver.findElement(By.xpath(".//*[@id = content ]/p[2]/span/font/b")).getText();
// Print a Log In message to the screen
System.out.println(" The Result is " + result);
if(result.equals("5")) {
System.out.println(" The Result is Pass");
} else {
System.out.println(" The Result is Fail");
}
}
@AfterTest
pubpc void closeBrowser() {
driver.quit();
}
}
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name = "Suite" parallel = "tests">
<test name = "FirefoxTest">
<parameter name = "browser" value = "firefox" />
<classes>
<class name = "TestNG.TestNGClass" />
</classes>
</test>
<test name = "ChromeTest">
<parameter name = "browser" value = "chrome" />
<classes>
<class name = "TestNG.TestNGClass" />
</classes>
</test>
<test name = "IETest">
<parameter name = "browser" value = "ie" />
<classes>
<class name = "TestNG.TestNGClass" />
</classes>
</test>
</suite>
Test Execution
Result Analysis