Showing posts with label Selenium/WebDriver. Show all posts
Showing posts with label Selenium/WebDriver. Show all posts

Saturday, 1 February 2014

Selenium 3 on its way!!!

Hello Friends,

Selenium Logo
Selenium has been a great tool to automate browser related tasks. Now community developers are working on to release Selenium 3. We hope lots of new features to be included in this release.

Check below link for more information!!
Selenium 3 is coming






Thanks
Dibyaranjan

Sunday, 14 April 2013

Finding Parent Element in Selenium/WebDriver

Hello All,

This post tells about finding parent element of any element using Selenium/Web Driver. Many times we need to perform some action on elements based on their parents. This post will give you some idea to find out the parent element by using xpath.

Code:

//##################################################//
public WebElement GetParentElement(WebElement elem)
{
    WebElement parentElem=null;
    if(elem !=null)
    {
        parentElem=elem.findElement(By.xpath(".."));
    }
    return parentElem;          
}
//##################################################//


Thanks
Dibya

Saturday, 3 November 2012

Selenium 2.26 Released!!!

Hey Guys,

Selenium 2.26 release, yet to hit SeleniumHQ but if you want to download then click on below link.
Selenium 2.26 download link.

Here is the Change Log :

v2.26.0
=======
WebDriver:
  * Updated OperaDriver to 0.15.
  * Added transparency support to the Color class.
  * Increased lock time a bit for the FirefoxDriver to make tests more 
    stable on Windows.
  * Added the enablePersistenHover capability to allow the user to specify
    whether to use the persistent hover thread in the IE driver. Defaults
 to true for IE.
  * Added support for native events for Firefox 15 and 16.
  * Removed deprecation from ChromeDriver constructors that take a Capabilities
    object. Also added a method to set experimental options in ChromeOptions
 which may be used to set options that aren't exposed through the ChromeOptions
    API.
  * Fixed SafariDriver to allow calling .quit() consecutively without error.
  * Modified FirefoxDriver to use atoms to switch between frames.
  * FIXED: 4535: Hover still does not work perfectly in IE.
  * FIXED: 4676: Unable to fire javascript events into SVG's. 
  * FIXED: 4320: Impossible to IE run tests in parallel via TestNG.
  * FIXED: 4309: 'Could not convert Native argument arg 0' error with Firefox.
  * FIXED: 4593: Alert.accept() Cancels the Resend Alert/Dialog Box.
  * FIXED: 4321: Upgrade HtmlUnitDriver to HtmlUnit 2.10.
  * FIXED: 4639: Webdriver 2.25 fails to quit on Windows.
  * FIXED: 3774: New SafariDriver sessions do not come with a clean profile.
  * FIXED: 4375: Executing javascript hangs Firefox.
  * FIXED: 4203: Java SafariDriver has limited websocket frame size.
  * FIXED: 4165: WebDriver fails on a machine with no IP address.
  * FIXED: 3969: SafariDriver should auto-dismiss alerts.

WebDriverJS:
  * FIXED: 4648: findElement errros not helpful.
  * FIXED: 4687: webserverjs cannot find module in node.js.
  * FIXED: 4649: Wrong Content-Length calculation in webdriverjs.
  * FIXED: 4425: Webdriver.js regression: webdriver.By.* selectors defect when
    using Node.js.

Grid:
  * FIXED: 4433: NPE at grid launch if invalid servlet class name is specified.
  * FIXED: 4526: elenium node stop responding when there are 2 or more tests
    waiting for a specific node.
  * FIXED: 2549: "-role hub" doesn't allow Firefox to starts.

Thanks!!

Sunday, 14 October 2012

Introductory training video to Selenium/Java

Hi All,

I was watching some videos related to Selenium/WebDriver, found this one very helpful for beginners. Please watch this video if you want to work on Selenium and java.  This video basically talks about java for beginners.

Note-: I have not prepared this video, this is a just a reference to the people who wants to work on selenium and also follow my blog.



Thanks!!

Sunday, 7 October 2012

Selenium Selectors XPath or CSS which one is your favourite?

Hey Guys,

If you people have ever written any selenium scripts, you must be aware of XPath and CSS selectors. They are the most used selectors in Selenium especially XPath. There are other selectors like ID,Class Name, Name, Link Text though exist and you can use them but XPath and CSS gives you an edge while finding an element in  complex HTML structure. Ok so which one is better? XPath or CSS????

In my experience so far, I have used XPath selectors/locators in selenium but in recent times they are my last options to use, Yes I mean, I prefer CSS before XPath. Reason is very simple, XPath is slow. I do write all my tests for IE browser and IE does not support XPath natively and it is damn slow in IE. But as I said, It is my last option that mean, i know when no other selectors finds me an element, XPath is the saviour.

Here I am posting a video by Sauce which is showing  a comparison between XPath and CSS, a really nice video to watch.


Watch the video, and share your experiences with XPath and CSS selectors in Selenium also. Please give your valuable comments to improve the blog. 

Thanks!!

Sunday, 30 September 2012

Handling Alerts in Selenium/WebDriver

Hello All,

It has been a long long time, when i wrote something for you guys on my blog. Got some time to write something, so today it will be related to handling alerts in selenium/webdriver.This post is written keeping Selenium 2.0 in my mind. So it may not hold good for Selenium RC users.

Selenium can handle  java script alerts in a very effective manner but it can not handle modal alert box which gets created by OS itself e.g.:  java script error message alert. Now how do you handle these java script alerts, what can you do with those alerts, lets see one by one with the code.

Let us take a Scenario as an example -:
 Select a object from the page, Click on Delete button. It triggers a alert saying "Object is going to be deleted from the database, Click OK to Confirm or Cancel to Cancel the Operation".

We need to test the message of the Alert, Clicking Ok and Clicking Cancel also.
Steps to be Performed
=========================
Select the Object to delete from the page.
Click on Delete button, it triggers the Alert message.




/* Code to switch the control to Alert message*/
Alert testAlrt=driver.switchTo().alert();
testAlrt is the Controlling object of the Alert. Now you can use this object to Accept/get Text/Dismiss the alert.

/* To get the text from the alert */
String sAltText=testAlrt.getText();

/* To Accept any alert, it means Clicking OK button */
testAlrt.accept();

/* To dismiss any alert, It means Clicking Cancel button */
testAlrt.dismiss();

/* If the Alerts gets created using Ajax call, then you may need to wait till the Alert present */
WebDriverWait wdWait= new WebDriverWait(driver, 10);
wdWait.until(ExpectedConditions.alertIsPresent());



This is all about handling Alerts in your Selenium test scripts. Please give back a feedback about the post.

Thanks!!

Saturday, 18 August 2012

Handling Popup Windows in Selenium/WebDriver

Hello Everyone, 
            Today i will be blogging about THE most asked question about selenium/webdriver. That is, switching to popup window using web driver. I heard this question from many people, saw it as a question/explanation in many blogs. 
       I found it difficult while implementing Selenium in my company also. The situation is gets worse when there is more than 1 popup at a particular time and window names are same -:(. This is bad, isn't it?
         Ok let us see the solution now. CODE it DOWN!! Before that create a test scenario. You have a application, you login to the application, Home page shows up. Click on any link, it opens up a popup window,You have to do some operation in that window.

Below is the code to for the above scenario. Let me explain one by one.



See the second line of code, 
String sWinHndl=wd.getWindowHandle();

In the above line of code, we are fetching the current window handle. This you need to take for the home page in the above test scenario.

Why are we doing this?
Here goes the explanation, this is really required for you to understand. When you do have main window and popup window title same then there is only one thing left which is different i.e. Window Handle. a unique number generated for each and every window. We need to play with that id in the code.

Next line is for your test code to do some operation to open up the pop up window. Your pop up window is open now. Now there are 2 window handles currently present.
Explanation for next line of code is like -:  You already have X(sWinHndl) and now you have X & Y (lisOfWinds). Compare if it is not X then switch i.e. switch to Y.

This piece of code will only work if there are 2 windows opened at a particular time. But how do you handle it for more than 2 windows, for each window you open, do you want to keep the window handle?? Think and let me hear from you also. Trick is still in the window handles, see how you can use it effectively.

Please feel free to drop a comment if you found this information is helpful for you. If you have any comment/suggestion/issue with anything mentioned above, then also please share it with us.

Thanks!!

Sunday, 12 August 2012

Select Option from Drop down box using WebDriver

It has been quite some time, added any post related to Selenium/WebDriver. Today i will be going to write about selecting a option value from drop down box. Selenium provides a Select class to do that, it is pretty easy to use. Ok lets have one sample html for our demonstration-:






We will see now how to select options using selenium/webdriver's Select class. Below code explains how to use select class to select option from drop down box.



 Apart from the above 3 methods, there are other methods which can be used to perform other actions also.
Here is the link for Select Class methods.

Please feel free to drop a comment if you have any suggestion/comment/Issue related to the above post.

Thanks!!!

Related Posts

Related Posts...