i
WebDriver Introduction
Selenium WebDriver Architecture
Introduction to WebDriver API
Introduction to WebDriver – Code
Handling Dropdowns and Select class
Handling Multiple Dropdown values and Links
Handling Radio buttons and Checkboxes
Capture Screenshots and Email test results
Browser Navigation Methods
Handling tabs
Capturing screenshot, Handling tabs and pop-ups – Code
Handling tabs and Pop-ups – Code
Handling Alerts
Handling User Authentication and Input alerts
HtmlUnitDriver and Handling Captchas
Handling Web Tables
Synchronization
Handling WebTables, Synchronization issues, Firefoxprofiles – Code
Actions Class
Event Listeners, Event Firing Mouse, Coordinates – Code
Handling Mouse Hover in Selenium
JavascriptExecutor
Handling Iframes
IsElementPresent, IsEnabled, IsSelected
Working with Chrome Driver - Part 1
Working with FireFox Driver - Part 2
Working with Internet Explorer Driver - Part 3
Handling SSL Certificate
Desired Capabilities
How to Encode password in WebDriver
Handling JQuery Elements - Drag and Drop, Sliders, Resizable
Handling JQuery Elements - Drag and Drop, Sliders, Resizable – Code
Working on IE Browser using Actions
TestNG, Ant & Report Generation through XSLT
Introduction to TestNG and Annotations
TestNG Parameterization
Configuring ANT, Generating TestNG & XSLT Reports
Code for generating XSLT / Surefire Reports through MAVEN
TestNG Parameterization Excel Reading
Handling Multiple data providers
TestNG XSLT Jar, Build.xml & TestNG.xml file
Frameworks Introduction
Hybrid (DATA + KEYWORD) driven Framework
Framework Architecture
Reading Excel sheets
TestNG DataProvider
Data Provider with Hashtable
Handling Multiple Test Suites
Multiple DataProviders
Setting up Run-modes at Suite Level
Setting up Runmodes at TestCase Level
Creating a common utility for Run-modes
Hybrid Framework Code
We have got a variety of methods available in Selenium to handle events like a simple click() to click on some element, getText() to fetch the text out of an element, and sendKeys() to enter the texts in text boxes. We can handle the drop-down windows and radio buttons effectively.
Now the question comes why do we need to use Actions class then? The answer is, we see some critical situations where basic methods do not work correctly, and we need to have a more reliable solution to handle such complex scenarios such that double-click, drag and drop and element, Mouse hover, and many more.
What is the Actions class:
Selenium provides Actions class, which has compelling methods to solve a variety of complex operations.
Let us see the various methods of the Actions class by creating an instance of the Actions class.
So, we can see that a variety of methods are available under Actions class to automate situations like double-click, Click and hold, drag and drop, Mouse, and keyboard interactions.
We can test the login page of https://selflearning.io/login, where a user needs to click the "Shift down"+ "text"+ "Shift up" combination, then this set of sequential operations must be handled by a reliable solution like Actions class. Let us see how to handle this situation using Actions class.
Instantiation of Actions class:
We need to instantiate the Actions class first, and then we can perform the sequence of actions on the instance of Actions class.
Actions action=new Actions(driver);
Performing the Actions sequence:
So overall, we need to see the sequence of the actions:
1-Clicking on the "Shift" key—Using the "keyDown” method of Actions class.
2- Entering text on the text box- Using the "sendKeys” method of Actions class.
3-Releasing the "Shift" key- Using the "keyUp” method of Actions class.
WebElement eleSearch=driver.findElement(By.xpath("//*[@id='admin_login']/div[1]/input"));
action.keyDown(eleSearch,Keys.SHIFT).sendKeys("Testing").keyUp(eleSearch,Keys.SHIFT);
Now build the sequence:
As we have created a sequence in above step, now we need to build a composite action from all the actions in sequence. We use build() method of Action interface to collect the composite build action of all the actions present in Actions sequence.
Action builder=action.build();
Perform the composite action:
Now we have built the composite action. We need to perform this composite action by using the perform() method of Action interface.
builder.perform();
We can also perform the composite action without using the Action interface as below:
action.keyDown(eleSearch,Keys.SHIFT).sendKeys("testing").keyUp(eleSearch,Keys.SHIFT).perform();
Note: Here we can observe that we have not used build() method before using perform() method. This is because the perform() method is also available in Actions class and this method automatically builds the sequence internally, so we do not need to explicitly expose it.
Don't miss out!