public static void main(String[] args) throws InterruptedException,
			IOException {
		WebDriver driver = Utils.createFireFoxDriver();

		Utils.openTvdb(driver, null);
		(new WebDriverWait(driver, 10)).until(ExpectedConditions
				.elementToBeClickable(By.partialLinkText("JU@")));
		driver.findElement(By.partialLinkText("JU@")).click();

		// Setup units of tables
		(new WebDriverWait(driver, 30)).until(ExpectedConditions
				.presenceOfElementLocated(By.tagName("table")));

		SortedMap<String, List<String>> tableUnits = new TreeMap<String, List<String>>();
		Set<String> unitSet = new HashSet<String>();

		Utils.obtainTableUnitMapping(tableUnits, unitSet);

		// Read tables filler table and construct the mapping
		List<WebElement> trs = driver.findElement(By.tagName("table"))
				.findElements(By.tagName("tr"));
		
		trs.remove(0); // remove table header
		
		for(WebElement tr: trs) {
			List<WebElement> tds = tr.findElements(By.tagName("td"));
			String tableName = tds.get(1).getText();
			tableName = tableName.replaceFirst("^table", "").replace("_", "-");
			WebElement unitTextField = tds.get(5).findElement(By.tagName("textarea"));
			if(unitTextField.getAttribute("readonly") != null) {
			    System.err.println("Readonly text-field: " + unitTextField.getText() + "; skipped");
			    continue;
			}
			unitTextField.clear();
			unitTextField.sendKeys(StringUtils.join(tableUnits.get(tableName), ","));
		}

		// Uˮ֩
		Utils.obtainDTableUnitMapping(tableUnits, unitSet);
		trs = driver.findElements(By.tagName("table")).get(1).findElements(By.tagName("tr"));
		trs.remove(0); // remove table primary header
		trs.remove(0); // remove table secondary header
		
		for (WebElement tr : trs) {
			List<WebElement> tds = tr.findElements(By.tagName("td"));
//			String checkerIdx = tds.get(0).getText();
			String checkerName = tds.get(2).getText();
			Set<String> units = new HashSet<String>();
			
			Utils.obtainUnitsOfChecker(checkerName, tableUnits, units);
			
			WebElement unitTextField = tds.get(5).findElement(By.tagName("textarea"));
			unitTextField.clear();
			unitTextField.sendKeys(StringUtils.join(units, ","));
		}
//		((JavascriptExecutor) driver).executeScript("alert('ЦbT{L~U [xs], ïdNO_[|pU]Bz!')");
		driver.findElement(By.cssSelector("input[type=submit][value=Twxs]")).click();
	}