Skip to content

Instantly share code, notes, and snippets.

@ddavison
Created May 9, 2014 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddavison/78d64de72195ecddc359 to your computer and use it in GitHub Desktop.
Save ddavison/78d64de72195ecddc359 to your computer and use it in GitHub Desktop.
JavaPackages - using the [getting-started-with-selenium](http://github.com/ddavison/getting-started-with-selenium) framework
package com.company.seleniumframework.functional;
import com.company.seleniumframework.AutomationTest;
import com.company.seleniumframework.Browser;
import com.company.seleniumframework.Config;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.ArrayList;
import java.util.List;
/**
* Thought i'd spend some time, because I was curious myself on how many packages there were :)
* SO # 23573872
* http://stackoverflow.com/questions/23573872/number-of-packages-in-java-8
* Created by ddavison on 09/05/2014.
*/
@Config(url="http://docs.oracle.com/javase/8/docs/api/overview-frame.html", browser= Browser.CHROME)
public class JavaPackages extends AutomationTest {
@Test
public void doIt() {
List<String> packages = new ArrayList<String>();
List<WebElement> lis = driver.findElements(By.cssSelector("ul[title='Packages'] > li"));
for (WebElement pkg : lis)
for (String subpkg : pkg.getText().split("\\."))
if (!packages.contains(subpkg))
packages.add(subpkg);
log(packages.size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment