to to get the value of src from the DIV

13 views
Skip to first unread message

SRK

unread,
Mar 25, 2015, 5:22:41 PM3/25/15
to seleniu...@googlegroups.com
Hi , can some one help me here in getting the value of src from the div , as I am getting the error " element not found " exception . I have tried all the options of using xpath, By.className, etc. Below is the code, i want the value captured in the highlighted color below

<hr class="product_detail-right-divider">
<div class="quick_info-right-delivery">
<div class="quick_info-right-delivery-home quick_info-right-delivery-section">
<div class="quick_info-right-delivery-icon">
<img alt="Home delivery within 90 days" src="/wcsstore/abcStorefrontAssetStore/images/quick_info/90days.png">

Thanks in advance
SRK

Shawn McCarthy

unread,
Mar 25, 2015, 10:15:11 PM3/25/15
to seleniu...@googlegroups.com
How about this :

driver.findElement(By.cssSelector("img[alt='Home delivery within 90 days']").getAttribute("src");

Ravi Mundhe

unread,
Mar 25, 2015, 10:23:55 PM3/25/15
to seleniu...@googlegroups.com
Try this:

String imgSrcValue;   //Create string object 'imgSrcValue' 
imgSrcValue = browser.findElement(By.xpath("//img[@alt=’Home delivery within 90 days’]")).getAttribute("src");
// The field value is retrieved by the getAttribute("src") Selenium WebDriver predefined method and assigned to the String object. 

Thanks,
-Ravi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4baa6c00-9ba0-47db-a7d7-cd2a1e04e1ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Thanks & Regards
Ravi S. Mundhe


Reply all
Reply to author
Forward
0 new messages