Search code examples
javarubyeclipsewatirwatir-webdriver

How to use Watir for web app testing on Java?


I've been assigned by our prof as the QA tester of our thesis web application and he wanted me to use Watir for testing the web application. But, I'm currently split as to how I'm supposed to approach this.

I know Watir is using Ruby as it's main language, so should I study Ruby first?(I only have experience on Java, C++, and a little bit of Scala so far.) Or should I go straight to the documentations?

We're using Eclipse as our default terminal for the web app.


Solution

  • Yes, you need to know Ruby to work in WATIR, but it's very easy language, more closely put, it's syntax is neat and clean. And also WATIR is very easy to use and having very lesser code compared to selenium, I write code below using both WATIR and Selenium so that you could see the difference.

    To select a select_list in WATIR, you need to write the following code

    b.select_list(:id,'country').select 'India'
    

    The same equivalent in Selenium

    element=driver.findElement(By.id("country");
    Select var=new Select(element);
    var.selectByVisibleText("India");
    

    So you might have understand the difficulty level when you write code in Java using selenium.

    Ruby has a very rich Library so most of the functions would be readily available to you which you don't have code from your level.