18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to check position of the image on web page

edited November -1 in Sahi - Open Source
Hi,

I'm trying to get the location of the image on a web browser but not able to find it.

Also is there any way we can compare the saved image with the real time web page image.

Please help !!

Thanks in advance

Comments

  • Hi

    acces the image with _image("id"). With ".propertie" you can access a propertie like _image("id").height. When I list the properties of an image (here the _image("_sahi_ignore_7") on http://sahi.example.com/_s_/dyn/Driver_initialized ) it lists:
    scrollHeight=61;
    scrollWidth=161;
    clientHeight=61;
    clientWidth=161;
    height=61;
    width=161;
    offsetTop=464;
    offsetLeft=122;
    offsetWidth=161;
    offsetHeight=61;
    

    These attributes should help with the location. But I wouldn't recommend testing the location, the location can easiely change based on the browser, zoom, browser widow size etc.

    Regards
    Wormi
  • hey thanks

    I'm thinking to use _near or _in or _under API's for locating the image .

    But i dont know how to use it in case of a page where there is no "Table " or cell

    Can you help me in this?
  • You can use these APIs on any element on that page. Maybe there is a headline over your image?
  • There is a link above the image when i spy on the link it gives below name: _image("2701smallest.jpg")

    Let me know to put assertion for the location of the image.

    Thanks in advance!!
  • Hi,

    I use "bySeleniumLocator" to get position (selelnium grid).
    Selenium determines Xpath-position, so if ur sure that the image position is fixed, record the position using selenium and use it with sahi.

    Regards,
    Akshada
  • thanks Akshada , but can u providme the syntax for it. my image is -->
    _image("2701smallest.jpg")

    Thanks in advance!!
  • Hi Deepika,

    Install Selenium RC for your browser, click on the image. From the options provided, select Xpath-position.
    Use _bySeleniumLocator("xpath")

    Regards,
    Akshada
  • Thanks akshada,

    just one doubt whether the location/position will change w.r.t different browser?
  • Hi Deepika,

    I dont think so. Ideally it should not.
    Xpath depends on the XML document, so i think it has got nothing to do with Browser.

    Regards,
    Akshada
Sign In or Register to comment.