The document provides an overview of Selenium, including:
- The different versions of Selenium (IDE, RC, WebDriver) and how they work.
- How to locate elements using XPath, CSS selectors, and other methods.
- Common WebDriver methods for interacting with browsers and elements.
- Examples of handling different element types like dropdowns, radios, checkboxes.
- How to configure the Selenium Grid for parallel testing on multiple machines.
This presentation is about the following points,
1. Handle Browser,
2. Handle Edit box / Text Box,
3. Handle Link Element,
4. Handle Button,
5. Handle Text Area / Message,
6. Handle Dropdown box /List box,
7. Handle Radio Button,
8. Handle Check Box
Tellurium is a UI module based web testing framework. The UI module is a collection of UI elements you group together. Usually, the UI module represents a composite UI object in the format of nested basic UI elements. The UI module makes it possible to build UI elements' locators at run time. The framework does object to locator mapping (OLM) automatically at run time so that you can define UI objects simply by their attributes and write your selenium tests just like writing JUnit/TestNG tests. Since the framework constructs the actual locator automatically at run-time and it uses the Group Locating Concept (GLC) to exploit information inside a collection of UI components to help finding their locators, Tellurium is more robust, flexible, reusable compared with the Selenium testing framework.
This is a short version.
This presentation is about the following points,
1. Handle Browser,
2. Handle Edit box / Text Box,
3. Handle Link Element,
4. Handle Button,
5. Handle Text Area / Message,
6. Handle Dropdown box /List box,
7. Handle Radio Button,
8. Handle Check Box
Tellurium is a UI module based web testing framework. The UI module is a collection of UI elements you group together. Usually, the UI module represents a composite UI object in the format of nested basic UI elements. The UI module makes it possible to build UI elements' locators at run time. The framework does object to locator mapping (OLM) automatically at run time so that you can define UI objects simply by their attributes and write your selenium tests just like writing JUnit/TestNG tests. Since the framework constructs the actual locator automatically at run-time and it uses the Group Locating Concept (GLC) to exploit information inside a collection of UI components to help finding their locators, Tellurium is more robust, flexible, reusable compared with the Selenium testing framework.
This is a short version.
Automation Testing using Selenium WebdriverPankaj Biswas
This will help you to understand about automation testing and when to do automation on your application using selenium. How selenium works, how to find web elements and what operations we can perform on the web elements to do automation.
Testing mit Codeception: Full-stack testing PHP frameworkSusannSgorzaly
Codeception is a PHP testing framework for Behavior Driven Development, which covers all kinds of tests: unit tests, functional tests and acceptance tests. It is fast and simple in both usage and execution. This talk will give you a introduction to the software testing basics using codeception. It will also cover some stumbling blocks when writing tests, like:
- Test code stability against small changes
- Data stability
- Test structure
Last but not least I will give you a short outlook how to make your tests also understandable for product owners.
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxMikalai Alimenkou
Presentation from 10th SQADays conference in Moscow (December 2011) about different test design approaches to make functional tests on WebDriver more flexible, reliable and stable.
Edureka Selenium Interview Questions and Answers Tutorial will help you to prepare yourself for Selenium interviews. Learn about the most important Selenium interview questions and answers and know what will set you apart in the interview process.
Watch the video here to find out elaborate answers to these questions: https://www.youtube.com/watch?v=6HS8-u96JJM
Automation Testing using Selenium WebdriverPankaj Biswas
This will help you to understand about automation testing and when to do automation on your application using selenium. How selenium works, how to find web elements and what operations we can perform on the web elements to do automation.
Testing mit Codeception: Full-stack testing PHP frameworkSusannSgorzaly
Codeception is a PHP testing framework for Behavior Driven Development, which covers all kinds of tests: unit tests, functional tests and acceptance tests. It is fast and simple in both usage and execution. This talk will give you a introduction to the software testing basics using codeception. It will also cover some stumbling blocks when writing tests, like:
- Test code stability against small changes
- Data stability
- Test structure
Last but not least I will give you a short outlook how to make your tests also understandable for product owners.
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxMikalai Alimenkou
Presentation from 10th SQADays conference in Moscow (December 2011) about different test design approaches to make functional tests on WebDriver more flexible, reliable and stable.
Edureka Selenium Interview Questions and Answers Tutorial will help you to prepare yourself for Selenium interviews. Learn about the most important Selenium interview questions and answers and know what will set you apart in the interview process.
Watch the video here to find out elaborate answers to these questions: https://www.youtube.com/watch?v=6HS8-u96JJM
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
In this slide, identify what to test and choose the best language for automation. Learn to write maintainable and reusable Selenium tests and add UI layout test as part of automation using Galen framework. This slide will also guide you in reporting structure by using external plugin's, an illustration covering cross browser testing (Running selenium grid with Docker) and explain Code repository (Git) and Jenkins CI tool.
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
Presentation from JAB-2014, I have talked about how we have setup PHPUnit and Selenium Webdriver for Testing Joomla CMS!,
How we can setup System test Suite for a Joomla! Component
Get Started With Selenium 3 and Selenium 3 GridDaniel Herken
In this talk you will learn how to:
- Setup Selenium 3 execution in Chrome, Firefox, IE and Edge
- Create and run a Selenium test
- Run tests against a Selenium Grid
More webinars can be found here:
http://www.browseemall.com/Resources/Webinars
• Want to test your entire Web 2.0 app, from AJAX and DHTML through browser-rendered
HTML into a live instance of your application and database? Most web testing frameworks
have gaps in their coverage: JUnit and Test::Unit miss the client frontend; JSUnit misses the
server backend; web testing frameworks miss some or all of the JavaScript. With Selenium
we have a framework that can test the whole application, from browser-executed JavaScript,
through a live application backend, then back to assertions on browser-rendered DOM code.
Selenium RC takes this further: since you write your tests in your application language, your
tests can do data setup and assertions based directly on server-side domain objects that
may be inaccessible or only partially accessible from the client side. On our teams we have
used and developed a series of helper methods and assertions that allow testing of AJAX
and DHTML functions as well.
2. • Selenium IDE (SIDE)
• Selenium 1.0 (Remote Control)
• Selenium 2.0 (WebDriver)
• Selenium Grid
Selenium - Suite
3. • It is implemented as a Firefox extension, and allow us to
record, edit, and replay the test in Firefox
• We can save tests as HTML, Java, C# or any other format
by supported/available code formatter ext.
• Give facility to add assertions to verify results
• Allow to add selenese commands as and when required
• Selenium commands, often called selenese like: clicking
button, entering text, marking check box, selection from
list etc.
Selenium IDE
4. • IDE recorded test cases can run only in Firefox
• No Programming logic (like loops, conditional
statements) can be applied
• Selenium IDE can only execute scripts created in
Selenes
• It is difficult to use Selenium IDE for checking
complex test cases involving dynamic contents
Limitations of Selenium IDE
5. • It is a API and Library of Selenium
• A server, written in Java so can work in cross platforms
• A solution to cross browser testing
• Acts as a proxy to send web requests by launching browser
• Client libraries for many popular languages, to get support we need to
configure first
• We need to create the selenium object by giving server and browser
details to before running test cases:
DefaultSelenium selenium=new DefaultSelenium(“System address”, ”Port
no of selenium”, “Browser to launch”, “url”);
• This selenium object provide us interface to perform keyboard and
mouse action on keyboard
Selenium 1.0 (RC)
7. What’s new
• Selenium 2.0 also called Selenium Web Driver
• Web Drivers are interfaces with language bindings
• WebDrivers are browser specific implementations
• Native keyboard and mouse interactions are supported
• Better support for handling popups and dialogs
• Supports running tests in mobile devices
• No need to start Selenium server unlike Selenium 1.0/RC
• WebDrivers available for language bindings – C#, Java,
Python, Perl, Ruby, PHP
8. Expr Desc Example
/ Select from the root node html/body/form/div[1]/center/table
/tbody/tr/td[1]/input
// Select nodes form the current node //table/tbody/tr/td[1]/input
@ Select attribute //input[@name=‘Login’]
Locating elements in Selenium
Through the HTML.. by
1. Tag name – a, input, select, span, div
2. Attribute – Name, Value, Id, type
3. Text - <title>Title of the document</title>
By Xpath
9. Example Desc
//input[@id='firstname’] Select element with tag input and id=firstname
//input[contains(text(),’Gmo ')] Select element with text containing Gmo
//input[starts-with(text(),’Enter’)] Select element with text starting with Enter
//input[contains(@value, “GMO")] identify element containing ‘GMO’ in value attribute
//input[contains(@id, "searchInput")
and contains(@text,“google")]
look at two attributes in input node
//input[starts-with(@type, “s")] find input node with attribute type and its value is starting
with 's'
//*[@accesskey=‘alpha'] Can use wild cards
//input[text()='First Name:'] Select element with tag input and text=firstname
//td/a/strong[contains(text(),'Socks')] Find all elements containing ‘Socks’
Examples: Locating elements
by Xpath
More: http://www.w3schools.com/xpath/xpath_syntax.asp
10. Selector Sample Desc
.Class .Button Selects all elements with class=“Button"
#Id #myForm Selects the element with id="myForm"
Element Select Selects all <select> elements
element, element Select , option elects all <select> and all <option> elements
element element Select option Selects all <select> elements inside <option>
elements
[attribute=value] [size='22'] Selects all elements with size=“22”
Element:first-child Select:first-child Select every <Select> element that is the first
child of its parent
Element:nth-child(n) Select:nth-child(2) Selects every <Select> element that is the second
child of its parent
Element:last-child Select:last-child Selects every <Select> element that is the last
child of its parent
Element:checked input:checked
Examples: Locating elements
by Css Selector
More: http://www.w3schools.com/cssref/css_selectors.asp
11. • Firefox
ff=new FirefoxDriver();
• IE
System.setProperty("webdriver.ie.driver", “D:Selenium
ProjectsBrowserDriversIEDriverServer.exe");
ie=new InternetExplorerDriver();
//ensure protected mode is turned off/on for all zones under security tab
//set zoom level to 100%
• Chrome
System.setProperty("webdriver.chrome.driver", "D:Selenium
ProjectsBrowserDriverschromedriver.exe");
chrome=new ChromeDriver();
//ensure auto update is turned off
Working with Browsers
12. Method Desc
.get(String url) Navigate to url
.navigate().to(String url) Navigate to url
.navigate().back() Navigate to the previous page in thecache
.navigate().forward() Navigate to the next page in thecache
.getTitle() Pagetitle
.close() Close the current instance of thebrowser
.quit() Close all instances of thebrowser
.findElement(By.xpath(xp)) Locate element byxpath
.findElement(By.name(name)) Locate element by nameattribute
.findElement(By.id(id)) Locate element by idattribute
.findElement(By.className(cls)) Locate element byclass
.findElement(By.cssSelector(selector)) Locate element by cssselector
.findElements(By.tagName(tagname)) Locate all elements having tagtagname
Commonly used WebDriver
methods
13. Method Desc
element.getText() Retrieves the text of the givenelement
element.clear() Clears the value from inputelement
element.sendKeys(chars) Input value into element
.manage().window().maximize(); Maximize window
.manage().timeouts().pageLoadTimeout
(10,TimeUnit.SECONDS);
Page load time
element.isDisplayed() Check if element is displayed – returnstrue/false
element.isEnabled() Check if element is enabled– returnstrue/false
Commonly used WebDriver
methods
14. • Input field
WebElement field = driver.findElement(By.name("QTY_TENTS"));
field.clear(); field.sendKeys(value);
• Drop Down box
Select selection = new Select(browserDriver.findElement(By.xpath("//select[@name='CardType']“));
List<WebElement> options = selection.getOptions(); elementSize=options.size();
selection.selectByIndex(1); / selection.selectByVisibleText(“visa”);
• Radio
driver.findElement(By.xpath("//input[@value='oneway']")).click();
• Check box
isChecked=driver.findElement(By.name("shipSameAsBill")).isSelected();
driver.findElement(By.name("shipSameAsBill")).click();
• Handle popups
driver.switchTo().alert().accept(); driver.switchTo().alert().getText();
WebDriver Snippets
15. • Auto-suggest Drop down (google.co.in)
driver.findElement(By.cssSelector(“. gbqfqw").sendKeys(value);
driver.findElement(By.cssSelector(“#gbqfqw").sendKeys(Keys.DOWN);
driver.findElement(By.cssSelector(“div#gbqfqw”).sendKeys(Keys.UP);
• List out the options in the selection box
WebElement select = driver.findElement(By.name('CardType'));
List <WebElement> options = select.findElements(By.tagName("option"));
for (WebElement option : options) {
String name = option.getAttribute("value"); System.out.println("value:"+name); }
• Switch to frame
driver.switchTo().frame( "frameName" ); driver.switchTo().defaultContent();
• Handling Windows
Set<String> handles = driver.getWindowHandles(); nextWindowHandle=handles().iterator().next();
driver.switchTo().window(nextWindowHandle);
WebDriver Snippets
16. • Capture screen shot
File scrFile = ((TakesScreenshot) browserDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(“c:.filename.jpg"));
• Wait for an element – Explicit wait
WebDriverWait wait = new WebDriverWait(browserDriver, 10); //seconds
WebElement ele = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath ("//a[contains(text(),'Java
training')]")));
• Implicit Wait – applies to all elements
browserDriver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
• Simulate mouse actions
Actions mouseAction= new Actions(driver);
WebElement menu = wd.findElement(By.xpath("//a/span[text()= 'Books & Media']"));
mouseAction.moveToElement(menu).perform();
WebDriver Snippets
18. Firefox profile
• A profile in Firefox is a collection of bookmarks, browser settings,
extensions, passwords, and history; all of personal settings.
• Why use profile when executing selenium tests?
• Webdriver always creates an anonymous profile with default settings,
so sometimes tests may behave differently at times
• Tests may require some proxy settings which doesnot come with default
settings which webdriver creates.
• SSL certificates or some browser plugins may be required to successfully
execute the tests.
• Procedure:
• Create a new profile and use in the test
• Create firefox profile through script
19. • Create a new profile and use in the test
• From windows start/run : firefox.exe -P
• Create a new profile. Select the profile, start firefox, apply settings.
• In selenium script, code the following and examine new firefox browser is opened with
applied settings.
ProfilesIni pi = new ProfilesIni(); FirefoxProfile fp = pi.getProfile("SelTests");
browserDriver=new FirefoxDriver(fp);
• Create firefox profile through script with proxy settings
FirefoxProfile fp = new FirefoxProfile(); fp.setEnableNativeEvents(true);
fp.setPreference("network.proxy.type", 1); // manual proxy setting
fp.setPreference("network.proxy.http", "localhost"); // specify ip (or localhost)
fp.setPreference("network.proxy.http_port", 8080); // specify port
browserDriver=new FirefoxDriver(fp);
Get these properties by typing “about:config” in Firefox browser
Firefox profile
20. Exceptions Desc
ElementNotVisibleException Thrown when although an element is present on the DOM,
it is not visible, and so is not able to be interacted with.
NoAlertPresentException Thrown when switching to alert which is not present.
NoSuchElementException Thrown when element could not be found.
TimeoutException Thrown when a command does not complete in enough
time.
UnexpectedAlertPresentExceptio
n
Thrown when an unexpected alert is appeared.
StaleElementReferenceException Thrown when a reference to an element no longer appears
on the DOM
ElementNotFoundException page not loading fast enough or element not yet loaded
Selenium Exceptions
21. Grid 2.0
• Run tests in parallel
• Run tests in multiple machines – Physical/Virtual
• Consists of hub and one or more nodes
• Hub
• provides the configurations or capabilities to the Selenium
WebDriver tests
• receive the entire test request and distribute it to the right
nodes
• Nodes
• connects to hub for parallel execution
22. Grid Configuration
• Hub m/c
Standalone jar run as hub
Listens to configured nodes on port 4444 (default and can be
changed)
java –jar selenium-server-standalone-2.xx.x.jar –role hub [-port xxxx]
• Nodes m/c
Standalone jar run as node with browser, OS configuration with any
open port
• Execute
Run the test code from eclipse/IntelliJ or supported IDE
24. • From IntelliJ
• Add TestNg jar file to libraries
• Create TestNg test class and create test code methods with relevant
TestNg annotations
• Run the test code using TestNg test
• Using Testng.xml
• Create testng.xml – manual
• Create testng.xml - Eclipse-TestNg needs to configured in eclipse
• Run the xml file
‒ From command line
‒ From Ant – download/configure Ant from within eclipse
‒ From Maven – download/configure Maven from within eclipse
Grid - Test Execution via
TestNG