Category: 3. Watir

  • Browser Windows

    You will come across cases where we have to use popup window or opening of a new browser window. In this chapter, we will discuss how to test such cases using Watir. Syntax browser.window Output On-click of button Open Window, the popup window opens up. Here, the url we have given is www.google.com. Now let us…

  • Downloads

    We have buttons or links in the UI or our website which downloads a pdf, or a doc. We can test that for using with Watir by giving some preferences to the browser. The prefs has download wherein we need to give the path where we want the file to be stored after download and…

  • Alerts

    Syntax Testpage Watir Code

  • Capturing Screenshots

    Ability to capture screenshots is one of the interesting features available with Watir. During the test automation, you can take screenshots and save the screens. In case, if any error occurs the same can be documented with the help of screenshot. A simple example along with test page where we have taken the screenshot is…

  • Mobile Testing

    For Mobile testing, we are going to use Desktop browser which will act as device browser for testing purpose. Let us understand its procedure in this chapter. To test your app on mobile browsers we need to install the webdriver-user-agent. Installing webdriver-user-agent Now, we are going to use the Webdriver useragent as shown in the…

  • Headless Testing

    In this chapter, we will learn how to use headless option of the Watir webdriver to test the page url. Syntax Browser = Watir::Browser.new :chrome, headless: true Output Watir code We have added the option headless : true to the Watir chrome browser. When you execute the Ruby program, it will not open the browser, everything will…

  • Automatic Waits

    In this chapter, let us understand waits in detail. To understand automatic waits, we have created a simple test page. When user enters text in the textbox onchange event is fired and after 3-seconds the button is enabled. Watir has a wait_unit api call which waits on a particular event or property. We will test the same…

  • Working with Iframes

    Watir offer easy to use syntax to work with iframes. Syntax browser.iframe(id: ‘myiframe’) // will get the reference of the iframe where we want to input details. To understand how to deal with iframes and locate the elements inside an iframe, in this chapter, we will work on an example. Example main.html test1.html Output In…

  • Locating Web Elements

    In Watir for testing, you need to locate the elements and it can be done in different ways – by using the id, class or text of the element. In this chapter, we will see few examples which shows different ways to locate elements. Using ID of the Element Test page Example In this example,…

  • Locating Web Elements

    In Watir for testing, you need to locate the elements and it can be done in different ways – by using the id, class or text of the element. In this chapter, we will see few examples which shows different ways to locate elements. Using ID of the Element Test page Example In this example,…