Skip to main content

Posts

Showing posts with the label How to - in Selenium WebDriver

How to Open Browser in Incognito / InPrivate mode using Selenium / WebDriver

How to Open Chrome Browser in Incognito mode using Selenium / WebDriver ?          We will use Chrome Drivers Capabilities & ChromeOptions to open Chrome browser in incognito mode. To be precise, we have to use argument --incognito  for ChromeOption as shown in below example- How to Open Firefox Browser in Incognito / Private mode using Selenium / WebDriver ?     We will use Firefox Profile   to open Firefox in private mode. To be precise, we will set browser.private.browsing.autostart in firefox profile preference. How to Open Internet Explorer (IE) Browser in InPrivate mode using Selenium / WebDriver ?       We will use IE Driver Capabilities to open IE in InPrivate mode. To be precise we will use FORCE_CREATE_PROCESS capability along with IE_SWITCHES to which parameter would be -private This is all for now. Cheers!!

How to open a new tab in a browser using Selenium WebDriver?

TL;DR :This is a story. If a story does not fascinate you, jump to the solution . Prologue :- If you constantly monitor many forums for some reason like LinkedIn groups, Google groups, Stackoverflow for Selenium related queries, you will find a question that has been asked many times with the same answer. Yes, I’m talking about the below question - How to open a new tab in a browser using Selenium WebDriver? Or this might have been asked in different style like - Open new tab instead of a new window using Selenium WebDriver You will easily find an answer after quick Google search. Why this post?             Because I do not agree with the most accepted answer of this question. I am not saying that solution provided is wrong or it won't work, I am just saying that I disagree with the solution provided. What is the solution provided by the way -  Here starts our story. Open a blank tab in a browser using Selenium WebDriver And very obvious solution would be use of sendKeys         

How to uncheck proxy server settings in chrome browser using Selenium WebDriver

If you have read my past post , you might know that I follow a lot of forums to understand what type of issues are faced by the community. This helps me to broaden my knowledge. A couple of days ago, I stumbled upon this question on such forum on Facebook. Question was- “ How to uncheck proxy server settings in chrome browser using selenium Code ?” with Below image. Proxy Server Setting for Browser That was a really interesting question, thanks for this question ‎ Roby Chauhan . Defining problem statement:- Uncheck proxy setting while invoking Chrome browser using Selenium WebDriver. Understanding Problem Statement :- I first tried to solve this question manually and realised once again that proxy setting that you applied in one browser are not just that browser specific but it OS specific. That means if you set proxy in one browser it is applicable to all browser. If you set the wrong proxy in one browser you would not able to connect to the internet using any browser. Refer image b

Highlight Element in Selenium WebDriver

  I missed highlighting object feature of QTP when I used to debug my selenium API call on webelement. Number of times I wondered, why didn't by default any method is provided to perform highlight action. But I no longer wish for same as I have found work around.         Remember this - ‘JavaScript comes in handy to perform any fancy tasks on DOM.’ Logic to perform highlight WebElement in Selenium WebDriver:-        To create highlight effect, as in QTP, we don't just need to highlight the element but also have to de-emphasize/play down the same element. Highlighting element once is not enough, as the operation would be fast and we may don't realise highlighting effect. Better we break down logic as in below steps:- Highlight element using javascript. Play-down same element using javascript. Perform above two actions in a loop for significant time. Below code demonstrate use of JavascriptExecutor to perform highlight element in Selenium WebDriver. As you can see

Object Repository in Selenium/Webdriver

From last 6 month or so, I am happily playing with Selenium API. Earlier, I invested more than 3 years in QTP / UFT . After spending that much of time in QTP, it’s very obvious that moving to selenium is not easy game and you cannot help yourself but compare this two things. You missed a lot of things from QTP when you move to Selenium, I can enlist few of those as follows:- Actions Datatables Checkpoints Smart Identifications Recovery scenarios Readily available test execution results and Object Repository and OR Manager This is not the complete list but still this are the majors which I have missed. “Journey becomes easy and better when you have good companion .” I went through many forums to find out good companion for learning selenium and finally settled on a book Selenium Testing Tools Cookbook by Unmesh Gundecha . When I started to learn selenium, I thought of  creating Object Repository in selenium. The book by Unmesh, itself was presented with recipe of implementation of O

Block Push Notification on Chrome in Selenium Webdriver

Many of you might already know that Chrome browser supports push notification  almost on all platforms from version 42  and many sites including Facebook and Google+ have already started delivering push notification for end users. So when it comes to automating such sites/apps first thing that you notice is browser asking permission to deliver push notification. Facebook asking for permission to show push notification Problem Statement:- As you can observe in above image that it would be impossible to perform immediate next action in browser after login as it’s been blacked-out. Chrome driver will wait for sometime (implicit wait) and then try to perform next step in browser, whatever it may be, it will fail and if you missed the step in execution which might cause failure of next step and result would be failed test/test suite. Also push notification badges are not getting displayed as part of web document, so clicking on those button displayed is not possible through selenium. Worka

Selenium as a Windows Service

I have been playing with selenium grid from past few days and it becomes very tedious to me to setup the grid by firing commands in command prompt [I am mostly windows 7 user]. So I thought of running selenium grid as service and for that I have used NSSM - the Non-Sucking Service Manager. To set up grid as service, obviously you need- Selenium-server-standalone-2.53.0.jar file (should work with other version but I have used this) NSSM Selenium Grid Hub setup:-     You need to have following files in folder ready to use before you start with this setup. My folder setup is like-     To set up hub, we use following command in the command prompt. java -jar selenium-server-standalone-2.53.0.jar -role hub Check whether grid hub is up and running as shown in below image- Now if you accidentally close your command prompt running, your hub will go down which used happen a lot to me as I was not very keen user of command prompt. By setting up this as service, anyone can get rid of orphan l