ITAG - Selenium WebDriver
ITAG - Selenium WebDriver
Phuong H H Nguyen
Principal QC Engineer
June, 2016
• Introduction
• Selenium WebDriver
– Introduction
– Selenium IDE
– Firebug and Firepath
– Cross-Browser Testing
– Locating Web Element
– Find multiple elements
– Click nth link with exact same label
– Attributes
– Execute script on another windows
– Click a button via JavaScript
– Set a value to a read-only or disable text field
– Select List
– Navigation and Browser
– Assertion
– Pop-up
– Advanced User Interactions
– Page Object
• ITAG (Intelligent Test Automation Generator)
• User defined functions
• Practice
• Operating Systems
OS Selenium IDE Selenium Remote
Control
Windows Works in FireFox 2+ Start browser, run tests
• Programming Languages
Language Selenium IDE Selenium Remote
Control
C# Generate code Library ("driver") support
• An integrated development
environment for Selenium tests.
• Implemented as a Firefox
extension, and allows you to
record, edit, and debug tests.
• Features:
– Easy record and playback
– Intelligent field selection will use IDs, names, or XPath as
needed
– Auto complete for all common Selenium commands
– Walk through tests
– Debug and set breakpoints
– Save tests as HTML, Ruby scripts, or any other format
– Support for Selenium user-extensions.js file
– Option to automatically assert the title of every page
ID FindElement(By.Id("user"))
Name FindElement(By.Name("username"))
XPath FindElement(By.Xpath("//div[@id="login"]/input"))
• Click on the link will open the linked URL in a new browser window or tab.
– driver.FindElement(By.LinkText("Open new window")).Click();
– driver.SwitchTo().Window(driver.WindowHandles[1]); # change window
– driver.Close();
– driver.SwitchTo().Window(driver.WindowHandles[0]); // back
– driver.FindElement(By.LinkText("Recommend Selenium")).Click();
• Read-only and disabled text fields are not editable and are shown
differently in the browser (typically grayed out).
– ((IJavaScriptExecutor)driver).ExecuteScript("$('#readonly_text').val('bypass');");
Assert.AreEqual("bypass",
driver.FindElement(By.Id("readonly_text")).GetAttribute("value"));
– ((IJavaScriptExecutor)driver).ExecuteScript("$('#disabled_text').val('anyuse');");
• Go to a URL
– driver.Navigate().GoToUrl("https://google.com");
• Some other actions
– driver.Navigate().Back();
– driver.Navigate().Refresh();
– driver.Navigate().Forward();
– driver.Manage().Window.Maximize();
• Remember current web page URL and return to it later
– url = driver.Url;
–…
– driver.Navigate().GotoUrl(url);
• File upload
• HTML source
– <input type="file" name="document[file]" id="files" size="60"/>
• Test script
– String filePath = @"c:\work\testdata\users.csv";
– driver.FindElement(By.Name("document[file]")).SendKeys(filePath);
• JavaScript pop-ups
– IAlert a = driver.SwitchTo().Alert();
– a.Accept();
• ITAG Model
• System requirements
• Folder structure
• Test Case
• Test Suite
• Report
Automation
Test Enter data for Test Suite
Engineer and Test Case
Common Libraries
Log File
(Log.txt)
Report File
(Test_Report.xls)
System Requirements:
- Intel Core i
Software Requirements: - 4GB RAM
- Windows OS - IE 5.5 to 11.0
-.NET Framework 4.6 - FireFox 2 to 45
- Crystal Report Runtime - Chrome 2 to 46
-ITAG - 10GB disk free space
• ITAG
– Data: when running ITAG, data files will be generate to this folder
– Help: contains help files
– ThirdParty: contains the library file
– Tools: contains the executable file to launch ITAG GUI
@Step Parameters area: specifies parameters or values needed for the current
step
@Module Variables area: contains variables of module
– Log file
• Define object
• Create test case
• Create module
• Create test suite
• Run test script
• View report
Jun 2016 1.0 ITAG – Selenium WebDriver Phuong Nguyen Mai Nguyen, Quang To