SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Selenium with java - Image comparison

    hi,

    Selenium with java - web application

    I am testing web application, which is generating graph on the basis of data provided. I wanted to compare generated graph with expected image.

    Can any body tell me, how would I do this using selenium, is there any way to do that using selenium.

    Any pointer on this, would be great help.

    regards,
    Anni

  2. #2
    Junior Member
    Join Date
    Jan 2009
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Selenium with java - Image comparison

    I have done this using java programming, but i am interested in selenium functionality.
    Is this possible with selenium?

  3. #3
    Advanced Member tarun kumar's Avatar
    Join Date
    Jan 2007
    Location
    Bangalore, India
    Posts
    647
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Selenium with java - Image comparison

    How did you do this in java?

  4. #4
    Junior Member
    Join Date
    Jan 2009
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Selenium with java - Image comparison

    System.setProperty("Host","proxy");//change according to ur n/w
    System.setProperty("http.proxyPort","8080");
    URL yahoo = new URL(imageURL);
    HttpURLConnection connection = (
    HttpURLConnection)yahoo.openConnection();
    connection.connect();

    try{
    File f=new File("image.jpg");
    InputStream inputStream= connection.getInputStream();
    OutputStream out=new FileOutputStream(f);
    byte buf[]=new byte[1024];
    int len;
    while((len=inputStream.read(buf))>0)
    out.write(buf,0,len);
    out.close();
    inputStream.close();
    }catch(IOException ie){
    System.out.println(ie.printStackTrace);
    }

    image url u can find using selenium...

  5. #5
    Junior Member
    Join Date
    Apr 2007
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Selenium with java - Image comparison

    How did you do this in java?

    Can you send me the details of any pointers on kamleshjaware@gmail.com

  6. #6
    Junior Member
    Join Date
    Jan 2009
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Selenium with java - Image comparison

    //try this...
    package test;

    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.image.PixelGrabber;

    public class CompareImages {
    public static void main(String args[]){
    String file1 = "new_in_fp_logo.png";
    String file2 = "screen1.png";
    try {
    System.out.println("In Image Processing");
    Image image1 = Toolkit.getDefaultToolkit().getImage(file1);
    Image image2 = Toolkit.getDefaultToolkit().getImage(file2);
    //ColorModel defRGB=ColorModel.getRGBdefault();
    //int pixels[]=new int[195*49];

    PixelGrabber pg=new PixelGrabber(image1,0,0,-1, -1, false);
    PixelGrabber pg1=new PixelGrabber(image2,0,0,-1, -1, false);
    System.out.println("Entered try and catch, trying to grab pixels");
    pg.grabPixels();

    int[] data1 = null;
    if (pg.grabPixels()) {
    int width = pg.getWidth();
    int height = pg.getHeight();
    System.out.println("widht * hight = "+width+" * "+height );
    data1 = new int[width * height];
    data1 = (int[])pg.getPixels();
    }

    int[] data2 = null;
    if (pg1.grabPixels()) {
    int width = pg1.getWidth();
    int height = pg1.getHeight();
    data2 = new int[width * height];
    data2 = (int[]) pg1.getPixels();
    }

    System.out.println(" Image"+java.util.Arrays.equals(data1, data2));

    }
    catch(InterruptedException ie){
    ie.printStackTrace();
    }
    }
    }

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.34%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:30 AM.

Copyright BetaSoft Inc.