The page contains a Product name-(3 OF 3) GOLDEN GLOW ( DELUXE ). The product name has 6 different spans so we want to print the product name "GOLDEN GLOW ( DELUXE )", i.e including the all the spans so I have tried to use the and multiple time inside the [] but it didn't work. Below is the XPath:
//*[@class='itemTitleCopy no-mobile' and contains(@class, 'no-mobile') and contains(@class, 'sizeDescriptionTitle no-mobile') contains(@class, 'no-mobile') ]
Below is the HTML code:
<span class="m-shopping-cart-item-header-number">
(
<span id="itemNo-1" class="itemNo">3</span>
of
<span id="totalItems-1" class="totalItems">3</span>
)
<span class="itemTitleCopy no-mobile" id="itemTitleCopy-1">Golden Glow</span>
<span class="no-mobile">(</span>
<span class="sizeDescriptionTitle no-mobile" id="sizeDescriptionTitle-1">Deluxe</span>
<span class="no-mobile">)</span>
</span>
Update
Code trials:
WebElement checkoutShippingProdName = new WebDriverWait(getDriver(), 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@class='m-shopping-cart-item-header-number']")));
String shipProdElementHtml = checkoutShippingProdName.getAttribute("innerHTML");
String[] shipProdElementHtmlHtmlSplit = shipProdElementHtml.split("span>");
String currentProd = shipProdElementHtmlHtmlSplit[shipProdElementHtmlHtmlSplit.length -1];
currentProd = StringEscapeUtils.unescapeHtml4(StringUtils.trim(currentProd));
System.out.println("The Product Name is:" + currentProd);