Skip to main content

Posts

Showing posts from December, 2014

Selenium WebDriver WebElement Selectors

Hello friends.. 
This would be very besic topic for experianced people, but may help WebDriver new bees.
Basically whenever we interacting with Browser Application through WebDriver, we always need to identify the web-elements like Text-Box, Buttons, List, Dropdown, Menu, Link, Checkbox.. etc.         We use FindWebElement / FindWebElements method to locate/find Web-Elements, with different selectors.         But I will also like to mention here that as a Web-Application Tester, we should have basic knowledge of HTML & CSS, which definitely help us to take judgement on selectors to find the Web-Elements. 

Please go through below links to learn HTML / CSS

HTML Tutorials

CSS Tutorials

Below is the list of selectors provided by WebDriver. By.classNameBy.cssSelectorBy.id By.linkTextBy.nameBy.partialLinkTextBy.tagNameBy.xpath

Today i am going to explain some of the listed selectors. By.className              This Method takes Class Name as String and Finds elements based on the value of the "…

Best way to produce Logs in Selenium WebDriver

Hello Friends
While coding, it is very tedious task to create Log for each statement, although it is very helpful while digging the failures.
Logs are also very helpful for detailed investigation of failures and Exceptions. Recently, someone asked how to have Selenium Web-driver create Log if an exception is thrown. Here is how you do it
Normally you use following code to initializing Web-Driver
WebDriver driver; driver= new InternetExplorerDriver();
You need to Slightly Modify your Code as below
WebDriver driver; WebDriverEventListner eventListner = new MyEventListner(); driver = new EventFiringWebDriver(new InternetExplorerDriver()).register(eventListner);
And you need to add MyEventListener Class in your project and below is the the code of MyEventListener.java
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.events.WebDriverEventListener; public class MyEventListener implements W…

How to Handle PROXY Settings in Selenium WebDriver.

Hello friends..
Most of the time when we create any webdriver automation code using public websites like Google, Facebook, Yahoo... etc, which works very well at our home pc but not at office.
This may have various reasons. One of the reason is PROXY at your office network.
A proxy or proxy server is basically another computer which serves as a hub through which internet requests are processed. By connecting through one of these servers, your computer sends your requests to the proxy server which then processes your request and returns what you were wanting.

In this way it serves as an intermediary between your home machine and the rest of the computers on the internet. Proxies are used for a number of reasons such as to filter web content, to go around restrictions such as parental blocks, to screen downloads and uploads and to provide anonymity when surfing the internet.
To work your browser under proxy you may need below settings.
Internet Explorer Proxy SettingsClick ToolsCli…

Popular posts from this blog

Alternate Way for sendKeys

One of my friend called me yesterday, he had an interview on Selenium WebDriver and got confused on 1 Question.

What is an alternative for sendKeys Method in WebDriver? I also got stammered on this and thought in mind
Why the hell do we need this? There are below possible reason that I could find, When we need any alternative to sendKeys.
When the Text element is disabled or locked, sendKeys can not set the value in text field.
(in my opinion, this is not the correct way of Automation, because the element is locked or disabled by intend to not allow any text insertion)When we want to write huge text as input... that time the way WebDriver work, by sending Series of characters from String one by one, and Which is Very time consuming. so to minimize that time we can use this alternate method So now we have above two problems with sendKeys ......
Solution!!! The best alternative I found is JavaScript
Way 1 to Execute Script WebDriver driver = new FirefoxDriver(); driver…

Selecting Date on JQuery Datepicker

Hello Friends,

In this post we will see how to select specific date in JQuery Datepicker.

Its very easy to enter date as text by .sendKeys() method, but mostly when application uses JQuery Datepicker, it disables typing on the text-box. the text-box sets to read only.

While automating such screens we need to write logic which can interact with Datepicker and selects desired date.

Consider below example of Datepicker.


Html code for above example is


To automate this, we first break apart a problem.
Decide which date we want to set Read the current date from datepicker Calculate difference between both dates in Months(difference will positive in case of set date is in future respective to current date & will negative when set date is in past respective to current date of datepicker) Set loop depends on month difference and navigate the datepicker to specific month Select the Day. 
Lets implement the above logic.
Note: we have used Joda Date Time Library for calculate date and time …

XPATH Basics....

XPATH Basics...
XPath is a text syntax for locating parts of HTML document XPath contains a library of standard functions which helps to locate the WebElement XPath is a W3C recommendation
XPath uses path expressions to select WebElement or sets of WebElements in Web page. These expressions look very much like the expressions you see when you work with a traditional computer file system. like c:\MyFolder\another_folder\myFile.txt
XPATH terminologies Nodes While using Selenium WebDriver, we come across following three types of nodes
elementattributetext Look at below HTML code sample
Link to GoogleLink to YahooLink to FaceBook here div, a are element nodes (element is the basically type of WebElement). Attribute nodes for div element is class and its value is myLink"a" element has text nodes as Link to Google, Link to Yahoo, Link to FaceBook Relationship of Nodes There are various relations available in XPATH but as a selenium user we must have knowledge of below relations…