Showing posts with label selenium webdriver. Show all posts
Showing posts with label selenium webdriver. Show all posts

SelectorsHub is XPath, JSPath, cssSelector tool and it is very easy to understand and use. Earlier we learned how to install SelectorsHub in different browsers and basic features like how to get XPath or cssSelector of any web element to use it in selenium webdriver test script, using advanced featured from chrome devtool. I hope it has helped you lot to kick start learning it. Now we will look at few more features of SelectorsHub.

We have used many different tools and methods to find XPath and CSS selectors for selenium webdriver. But SelectorsHub is Next generation XPath and CSS selectors which is invented and created by Sanjay Kumar. It is very smart and intelligent IDE using which you can build XPath and CSSSelectors within 5 seconds without loosing your XPath and CSS selector writing skill for selenium WebDriver. It is supported in almost all popular browsers like Chrome, Safari, Firefox, Edge and Opera. It has so many features which we haven't seen in any other XPath and CSS Selectors IDE. It is free tool and save lot of your time. Earlier we had learnt ChroPath to find XPath or CSS Selectors of element.

In this post, We will learn how to install SelectorsHub in different browsers and usage of it's different features.

BrowserStack is web cloud platform which provides us an environment to test web and mobile applications on different version combinations of OS and browsers. BrowserStack provides limited access in Free trial version but you can get full access in Paid version's different plans. Many of you already aware about it's different features and usage. But still let me introduce you with browserstack little bit.

Earlier we already learn different selenium webdriver methods to add cookie, get cookies detail by name and all cookies. Sometimes you also need to delete all cookies from your browser in selenium webdriver test. Selenium Webdriver have built in deleteAllCookies() to Delete all cookies from current running browser window in test.

Earlier we learnt how to add cookie and get cookie details using different methods like addCookie(), getCookieNamed() and getCookies(). Sometimes you also need to delete cookie. Selenium webdriver have built in methods to delete cookies by deleteCookieNamed() or passing cookie object in deleteCookie() method.

Any site can have single or multiple cookies. If you know cookie name then you can get it's detail easily using getCookieNamed(). But if there are multiple cookies and you need all of them then you need to use getCookies(). It will retrieve all cookies of site you are navigating in selenium webdriver test. Here we will learn how to get all cookies using getCookies() and extracting all cookie detail using Java Set interface and Iterate through cookie set using Iterator.

Most of all you are already aware about browser cookie. Basically cookie is piece of data that is stored in your browser. It is sent from website you visit and mostly it is used to recognize if user return to website again. In sort, It tracks your website navigation journey. Cookie consist of different parameters like name, value, expiry, path, etc. Here we will see how can we add cookie and get cookie from browser in selenium webdriver using addCookie() and getCookieNamed().

Sometimes you need to set Dimension and Position of your browser window. Webdriver have built in Dimension and Position class with many different methods. We can use both these class and it's methods to set dimensions and positions of browser window. Let's see how we can use Dimension and Position methods to manage size and position

manage() method is very basic and we are using it very frequently in selenium WebDriver tests. You can use it to manage size and positions of browser window during your test. You can use it to add or delete cookie, get cookie, timeouts, waits and there are many other usages as well but here we will discuss about how to maximize browser or set it to full screen mode.

navigate() method is very frequently used method in selenium webdriver. Using this method, driver can navigate back, forward, refresh browser and navigate to specific URL. navigate() is very simple method and we can use it verify quickly in our selenium webdriver tests. Lets see how we can use navigate() method in selenium webdriver.

We can use switchTo() method when you want to switch between multiple browser windows or multiple frames on page. Earlier we had seen how to switch between two windows using getWindowHandles() and switchTo() methods. Here we will see how to switch between iFrames on page using switchTo() method by index of iFrame.

getwindowhandle() and getWindowHandles() are methods to get handle of window. getwindowhandle() is useful to get handle of current selected window or tab while getWindowHandles() will return handles of all open windows or tabs. Both these methods are useful when you are working with multiple windows and you need to switch from one window to another window.

Many new learners are initially confused about when to use close() and when to use quit() method in Selenium WebDriver. close() method will close the current instance of the webdriver object reference. In simple word, It will close current window or tab on which your test is currently running. quit() methods will dispose webdriver object so it is also known as dispose method. In simple word, quit() methods will close all open browser tabs or windows.

As name suggest, getPageSource() method is useful to get source of last loaded web page. Please note here, If web page is modified(by javascript) after loading of page then getPageSource() may return page source of before modified page. You can get whole page source using this method and then you can use it as per your requirement.

Let's see how getPageSource() method can be used in selenium test.

Selenium Webdriver's findElement() method is useful to locate WebElement for page. It is one of the mostly used method in selenium webdriver. It uses By object as parameter can can use it with various element locating strategies like ID, Name, Linktext, Partial Linktext, Tag Name, Class Name, DOM Locator, CSS Selector and Xpath. findElement() will return first matching webelement from page.

findElements method is different than the findElement method in selenium webdriver. findElements method is useful to find all elements from page using given element locator strategies.You can locate all specific elements from page using class name, css selector, id, name, link text, partial link text, tag name or xpath. findElements will return list of web elements using given locator strategy and then you can iterate through list and perform action. Lets see how it works.

We are using getTitle() method very frequently in out selenium webdriver tests. It is one of the basic and most commonly used method. getTitle() method is used to get the title of currently loaded web page. Also it will strip leading and trailing white space from title if available. Also it can return null if title of the page is not present.

Selenium WebDriver have many different methods and one of them is getCurrentUrl() method. So what is the actual usage of getCurrentUrl() method and when to use it. Well, any one can get a clue about usage of getCurrentUrl() method from its name. It will simply return current URL of browser after loading the page.

Earlier we learnt about how to find XPath or CSS selector using Chrome Devtool to use it in selenium webdriver. ChroPath have same function with few additional feature which makes it more popular in selenium webdriver universe. Here i am presenting step by step guide to retrieve XPath or CSS selector of any web element using ChroPath chrome extension. Also we will look at few more useful features of ChroPath.

You can use SelectorsHub to Find XPath and CSS Selector.

Install ChroPath in Chrome
Before learning usage, You need to Install ChroPath in your chrome browser if it is not already installed. After Installation, Refresh your web page and it is ready to use now.

Finding XPath or CSS selector is very crucial task for selenium webdriver test script preparation and so google chrome has made it very easy for all and specially selenium users. There are many different chrome extensions available which provides this feature. But Google chrome's inbuilt Chrome Devtool is very easy to use. It has many other features as well but we will look at only XPath and CSS selector finder for now. Let's look it step by step.

Finding XPath/CSS selector of web element in chrome

Step 1 : First of all, Open your web page in google chrome browser. I will use for this example. Here, we are going to find XPath and CSS selector of radio button with label Male.

Finding XPath of web element in chrome