Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Here's what I've done so far.

@Test
public void test() {

    String[] list = {};     

    for (int i=0; i<list.length; i++){

        driver.get(baseUrl + "/" + list[i]);    

        boolean text = driver.getPageSource().contains("meta");

        if(!text) {

            System.out.println(list[i]);
        }

    }
}

The problem is, this test returns false. It does not find the meta data.

Any idea why?

share|improve this question
    
Welcome to SQA, user3249785. Please edit your question to describe what you have done so far. Is this your first time to use JUnit? First time to use Webdriver? –  user246 Feb 4 at 16:17

2 Answers 2

You can match your text, if it is false, you can save the url. Try following:

String[] pages = {"http://google.com","http://yahoo.com"};
ArrayList<String> pagesWithoutMeta = new ArrayList<String>();
boolean isMetaPresent= false;
for (int i=0;i<pages.length;i++){
    String text = driver.findElement(By.xpath("//meta[@name='Description']")).getAttribute("content");
    isMetaPresent = text.contains("your text");
    /*Or you can do following:
     *isMetaPresent = driver.getPageSource().contains("your text");*/
    if(!isMetaPresent){
        pagesWithoutMeta.add(pages[i]);//If meta is not present add the url in an arraylist, which you can use or print later.
    }
}

Hope you get the idea.

share|improve this answer
    
I'll give this a try thank you. –  Ben Feb 5 at 17:58
    
Here's what I ended up using. –  Ben Feb 6 at 17:22
    
See above in the original post. –  Ben Feb 6 at 22:54

You can use Apache JMeter for this, it can handle things much faster as it doesn't spawn a real browser and sends HTTP requests (GET in your case) only.

You'll need:

  1. HTTP Request Sampler - to send requests
  2. CSV Data Set Config - to read URLs from file
  3. Response Assertion - to assure that metadata is present in the page source

There is also a WebDriver Sampler for JMeter if you would prefer using a real browser.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.