0

estoy intentando sacar un listado las img de un ul, identificando con el xpath el sitio fijo, primero: introducir la descripción de la imagen aquí

Creo que es primero llamar a todos los img y decir que si está dentro del xpath me debe pintar x = 5. Y me saca más de 5 imágenes que no están ese listado. No si algun@ me puede ayudar, gracias.

 public void seleccionarVestido() {
    

@FindBy(xpath = "(//ul)[21]")
    public WebElement listadoImagen;
    @FindBy(tagName = "img")
    public List<WebElement> hoverImagen;    
    for (WebElement webElement : hoverImagen) {
        String title = webElement.getAttribute("title");
        if (title.isEmpty() == false && listadoImagen.isDisplayed()) {
        
                System.out.println("img: "+ title);
            
            }
        }

Aquí os paso el código de HTML donde localizo el listado, en teoría me debe encontrar 5 pero me muestra 8. Espero que os sirva

<ul class="product_list grid row">      
                                <li class="ajax_block_product col-xs-12 col-sm-6 col-md-4 first-in-line first-item-of-tablet-line first-item-of-mobile-line" style="height: auto; margin-bottom: 0px;">
            <div class="product-container" itemscope="" itemtype="http://schema.org/Product">
                <div class="left-block">
                    <div class="product-image-container">
                        <a class="product_img_link" href="http://automationpractice.com/index.php?id_product=3&amp;controller=product" title="Printed Dress" itemprop="url">
                            <img class="replace-2x img-responsive" src="http://automationpractice.com/img/p/8/8-home_default.jpg" alt="Printed Dress" title="Printed Dress" width="250" height="250" itemprop="image">
                        </a>
                                                    <div class="quick-view-wrapper-mobile">
                            <a class="quick-view-mobile" href="http://automationpractice.com/index.php?id_product=3&amp;controller=product" rel="http://automationpractice.com/index.php?id_product=3&amp;controller=product">
                                <i class="icon-eye-open"></i>
                            </a>
                        </div>
                        <a class="quick-view" href="http://automationpractice.com/index.php?id_product=3&amp;controller=product" rel="http://automationpractice.com/index.php?id_product=3&amp;controller=product">
                            <span>Quick view</span>
                        </a>
                                                                            <div class="content_price" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
                                                                    <span itemprop="price" class="price product-price">
                                        $26.00                                  </span>
                                    <meta itemprop="priceCurrency" content="USD">
                                                                        
                                    
                                                            </div>
                                                                                            </div>                  
                </div>
                <div class="right-block">
                    <h5 itemprop="name">
                                                <a class="product-name" href="http://automationpractice.com/index.php?id_product=3&amp;controller=product" title="Printed Dress" itemprop="url">
                            Printed Dress
                        </a>
                    </h5>
                    
                    <p class="product-desc" itemprop="description">
                        100% cotton double printed dress. Black and white striped top and orange high waisted skater skirt bottom.
                    </p>
                                        <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer" class="content_price">
                                                    <span itemprop="price" class="price product-price">
                                $26.00                          </span>
                            <meta itemprop="priceCurrency" content="USD">                                                                       
                                            </div>
                                        <div class="button-container" style="">
                                                                                                                        <a class="button ajax_add_to_cart_button btn btn-default" href="http://automationpractice.com/index.php?controller=cart&amp;add=1&amp;id_product=3&amp;token=e817bb0705dd58da8db074c69f729fd8" rel="nofollow" title="Add to cart" data-id-product="3">
                                        <span>Add to cart</span>
                                    </a>
                                                                                                            <a itemprop="url" class="button lnk_view btn btn-default" href="http://automationpractice.com/index.php?id_product=3&amp;controller=product" title="View">
                            <span>More</span>
                        </a>
                    </div>
                                            <div class="color-list-container"><ul class="color_to_pick_list clearfix">
                    <li>
            <a href="http://automationpractice.com/index.php?id_product=3&amp;controller=product#/size-s/color-orange" id="color_13" class="color_pick" style="background:#F39C11;">
                            </a>
        </li>
    </ul>

6
  • pon tu html para poder reproducirlo el 25 mar. 2021 a las 14:33
  • Está arriba en captura y luego en el código tengo seleccionado dos FindBy. Es suficiente ?, está es la página: automationpractice.com/…
    – mgarciaQA
    el 26 mar. 2021 a las 7:29
  • no todas las personas son capaces de ver tus imágenes, esto debido a que no todos tienen las mismas capacidades visuales o están destrás de un proxy que les impide que carguen las imágenes el 26 mar. 2021 a las 15:27
  • Perdona, no lo sabía, os paso el código:
    – mgarciaQA
    el 27 mar. 2021 a las 16:59
  • @RuslanLópez, ya está el código HTML
    – mgarciaQA
    el 27 mar. 2021 a las 17:50

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.