Selenium 2.0 / Web Driver and Eclipse



Steps to set up web driver and Eclipse:
  1. Open Eclipse from the menu choose File, New, Project...
  2. In the folder Java, choose Java Project.
  3. Give project a name, accept the rest of the defaults, and click Next.
  4. Download the latest zip file for selenium frm : http://seleniumhq.org/download/
  5. The latest version right now is : "selenium-java-2.15.0.zip"
  6. Unzip the files into the project that you just created
  7. Back in Eclipse, right click on your project in the Package Explorer and choose Build Path, Configure Build Path.... Choose the Libraries tab
  8. Click Add Jars
  9. Select all of the jars that you just unzipped into the /lib/selenium-jars/ folder and click OK
  10. Choose the primary selenium jar, which in this example is selenium-java-2.15.jar , expand and  double-click on Javadoc location. (Enter the location for the Selenium JavaDocs into the Javadoc location path field htttp://selenium.googlecode.com/svn/trunk/docs/api/java/)
  11. Click Ok and u are ready.
  12. Right click on the /src folder in your project and choose New, Package...Give the package a name and click Finish.
  13. Right click on the package and choose New, Class...Give the class a name and accept the other defaults, but make sure that public static void main(String[] args) is checked.
  14. Add code from selenium IDE in JUnit4 (WebDriver) format 
  15. Run the test :)
Happy Testing!!! 

Comments

  1. Anonymous6/4/12

    Hi,

    I wish to set up the environment for selenium to test web based flash-flex UI.

    Could you please help me in this, I am totalyy new to selenium and flash flex.

    ReplyDelete
  2. Anonymous11/4/12

    Thanks Aditya. Helped me !

    ReplyDelete
  3. Anonymous3/12/13

    Your blog is very helpful. I am automating quikr and I have a doubt.
    My doubt is that while editing any add that you posted in quikr.com, then there is a subcategory field in the add.
    I think that is not a driopdown. After selecting the main category, corresponding subcategories are displayed there on the same dropdown (here i am saying dropdown but please do not get confused as that is not dropdown i think)...
    Now I am unable to select any subcategory from that field.
    Can you please help me out here.


    Please help how to select the value here...

    ReplyDelete
    Replies
    1. Hey thanks for the kind words. I checked quikr. You are right these are not drop-down elements but list items. You can access them by their ids or using XPATH like -
      Category - //*[@id='li_269']
      Sub Category - //*[@id='su_227']

      Hope this helps!

      Delete
    2. Anonymous4/12/13

      Hi,
      Thanks for quick response sir...
      By using the ids I can select Category/Sub Category. But here for selecting the category, I have created a method and in my testcase I am calling that method. And for that method, my code is below:-

      WebElement element = driver.findElement(By.xpath("//*[@id='subcatdiv']/ul"));
      List vals = element.findElements(By.tagName("li"));
      for(WebElement optionelement : vals){
      System.out.println(optionelement.getText());
      if(optionelement.getText().equalsIgnoreCase("Office Supplies")){
      optionelement.click();
      break;
      }
      }

      But I am unable to select the category/Subcategory.

      Kindly help me out here How can I achieve this.
      I need your help in this.

      Kindly help.

      Thanks
      amit

      Delete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?