- 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 - Webdriver
网络司机是自动化测试网络应用的工具。 它广为人知,为2.0ium。 网络驱动器使用不同的基本框架,而Selenium RC则使用Javales Selenium-Core, 嵌入浏览器内,但有一些限制。 网络司机在没有任何中间人的情况下与浏览器直接互动,不同于依赖服务器的Selenium RC。 在以下情况下使用:
多种浏览器测试,包括改进浏览器的功能,但没有得到Selenium RC的大力支持(第1.0期)。
处理多个框架、多个浏览器窗口、播种和警报。
复杂的页面导航。
先进的用户导航,如拖拉机。
AJAX-based UI要素。
Architecture
网络驱动器最好用简单结构图表加以解释,如下文所示。
Selenium RC Vs WebDriver
Selenium RC | Selenium WebDriver |
---|---|
The architecture of Selenium RC is comppcated, as the server needs to be up and running before starting a test. | WebDriver s architecture is simpler than Selenium RC, as it controls the browser from the OS level. |
Selenium server acts as a middleman between the browser and Selenese commands. | WebDriver interacts directly with the browser and uses the browser s engine to control it. |
Selenium RC script execution is slower, since it uses a Javascript to interact with RC. | WebDriver is faster, as it interacts directly with the browser. |
Selenium RC cannot support headless execution as it needs a real browser to work with. | WebDriver can support the headless execution. |
It s a simple and small API. | Complex and a bit large API as compared to RC. |
Less object-oriented API. | Purely object oriented API. |
Cannot test mobile Apppcations. | Can test iPhone/Android apppcations. |
Scripting using WebDriver
让我们理解如何与网络司机合作。 为了示范,我们将使用
<21>Step 2——通过点击Browse Button选择工作空间。
Step 5-Go to Libraries Tab and selected all the JAR ss that we havedown. 添加提及所有JAR的Selenium Web手图书馆夹,以及 se-java-2.42.2.jar和 se-java-2.42.2-srcs.jar。
Step 7——现在右翼插在包裹上,选择新到;>等级创建一类。
import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; pubpc class webdriverdemo { pubpc static void main(String[] args) { WebDriver driver = new FirefoxDriver(); //Puts an Imppcit wait, Will wait for 10 seconds before throwing exception driver.manage().timeouts().imppcitlyWait(10, TimeUnit.SECONDS); //Launch website driver.navigate().to("http://www.calculator.net/"); //Maximize the browser driver.manage().window().maximize(); // 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[2]/td/input[2]")).cpck(); // Get the Result Text based on its xpath String result = driver.findElement(By.xpath(".//*[@id = content ]/p[2]/font/b")).getText(); // Print a Log In message to the screen System.out.println(" The Result is " + result); //Close the Browser. driver.close(); } }
Most Used Commands
下表列出了网络司机的一些最常用的指挥及其辛勤。
Sr.No. | Command & Description |
---|---|
1 | driver.get(“URL”) 申请。 |
2 | element.sendKeys (“inputtext”) 将一些案文输入投入箱。 |
3 | element.clear() 明确投入箱的内容。 |
4 | select.deselectAll() 页: 1 |
5 | select.selectByVisibleText(“一些文本”) 选择使用人提供的投入。 |
6 | driver.switch To().window("windowName” 重点从一个窗口转移到另一个窗口。 |
7 | driver.switch To().frame(“frameName”) 从框架到框架。 |
8 | driver.switch To()。 帮助处理警报。 |
9 | driver.navigate(>URL”) 加入《欧洲刑法》。 |
10 | driver.navigate(>)。 前进。 |
11 | driver.navigate()。 取回。 |
12 | driver.close() 接近与司机有关的现有浏览器。 |
13 | driver.quit() 挖掘司机,关闭司机的所有相关窗口。 |
14 | driver.refresh()。 页: 1 |