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 get collection of images in a page

madanmadan Members
edited November -1 in Sahi - Open Source
Hi,

I am automating one application http://www.satyapaul.com, here click SAREES menu then Printed Embellished Sarees link, here we will get some images, in each page we will get 48 images, now i want all the images of that particular page into collection, means how can i get list of images by using "collectSimilar()" in sahi.

Regards,
Madan

Comments

  • Hi madan,

    You can use something like this:

    _collect("_image","/.*/",_accessor("document.body"));

    Regards
    Sumitra
  • Hi Sumitra,

    How can i use the code which you have sent in java mode.



    I tried with the below code in Eclipse and its giving the number of images of that particular page. but i am unable to click the image. Can you tell me why.

    List<ElementStub> st=browser.div("img").in(browser.table("four-grid")).collectSimilar();
    System.out.println(st.size());
    st.get(1).click();
  • Hi Madan,

    Try the following code:
    browser.navigateTo("http://www.satyapaul.com");
    List<ElementStub> st=browser.image("/.*/").in(browser.accessor("document.body")).collectSimilar();
    System.out.println(st.size());
    

    Also, make sure that you have imported the dependencies in tha java file.

    Regards
    Sumitra
Sign In or Register to comment.