RE: is it possible to get logo of any website using single script through selenium WebDriver.

I have 10 different website list and i want to get logo of these website using single script.
I am trying this script:-

driver.get(“http://www.road2argentina.com/”);

List<WebElement> images = driver.findElements(By.cssSelector(“a>img”));

for(WebElement image : images){
String s = image.getAttribute(“src”);
System.out.println(s);
if(s.endsWith(“logo.jpg”)){
System.out.println(s);
}else if(s.endsWith(“logo.png”)){
System.out.println(s);}

but problem is there every site give different logo name.

So please help me to resolve problem…..

Add Comment
2 Answers

Hi sratnesh

I learnt something from this website.. which i’m sharing my knowledge.. plz check weather it ll use for u.. 

driver.get(“http://www.road2argentina.com/”);

(“//img[contains(@src,’logo21.png’)]”);
// for redbus.in
//img[contains(@src,’logo.png’)]
//flipkart.com
//img[contains(@src,’flipkart_india-b1a41241.png’)]

 

Thank You

Train Answered on April 3, 2015.

yes above all useful but in your code if i need 20 website logo so i need to write 20 findElement code….

on April 5, 2015.

public class BaseLogo {
public void oneCommonLogictoGetLOGO(){

List<WebElement> images = driver.findElements(By.cssSelector(“a>img”));

for(WebElement image : images){
String s = image.getAttribute(“src”);
System.out.println(s);
if(s.endsWith(“logo.jpg”)){
System.out.println(s);
}else if(s.endsWith(“logo.png”)){
System.out.println(s);}
}

public class FindLogo extends BaseLogo {
public void FindLogoFunc(){
for (int i=0;i<Row.CountfromExcel+1;i++)  {
driver.get(“Cell value from Excel column URL of different websites”);
oneCommonLogictoGetLOGO();
}
}
}

I already told that LOGO image is very wide term lets take an example of it using iOS app
inside ios app if we say LOGO image then there are almost 5 type of logo images a UI designer adds to project which appears at different places in iPhone for app in question

1. Launcher app icon image
2. Logo image that appears in settings of iPhone device
3. Logo image while searching
4. Logo image while downloading app from Apple app store
all 4 logos have different resolution but same file type i.e. PNG

on April 6, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.