package web;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.SeleniumException;
public class WebSeleniumBaseTestCase extends SeleneseTestCase {
public static final String browserString = "*firefox E://TOES-dev//tools//Mozilla Firefox//firefox.exe";
public static final String DE_URL="https://ifop-app244.hkg.swissbank.com/";
public static final String FR_URL="https://ifop-app245.hkg.swissbank.com/";
public static final String IT_URL="https://ifop-app246.hkg.swissbank.com/";
public static final String UK_URL="https://ifop-app247.hkg.swissbank.com/";
public static final String MC_URL="https://ifop-app248.hkg.swissbank.com/";
public static final String JP_URL="https://ifop-app249.hkg.swissbank.com/";
public static boolean isSeleniumStart = false;
public static Map<String,String> locationMap = new ConcurrentHashMap<String,String>();
static{
locationMap.put("DE_URL", DE_URL);
locationMap.put("DE_USERID", "guolong");
locationMap.put("DE_PSW", "welcome1");
locationMap.put("DE_MCODE", "/safe-login/Login?handler=SAFELogin&locale=de_DE&SAFEGoto=http://dev.hkg.swissbank.com:18080/JTI/1/OrderBookFEWeb/m019/generalworkbench.do?method=showPage");
locationMap.put("DE_SUBMMIT", "//input[@value='Login' and @type='submit']");
locationMap.put("UK_URL", UK_URL);
locationMap.put("UK_USERID", "betsy");
locationMap.put("UK_PSW", "welcome1");
locationMap.put("UK_MCODE", "/safelogin/Login?handler=SAFEGetLogin&locale=en&SAFEGoto=http://dev.hkg.swissbank.com:18080/JTI/1/OrderBookFEWeb/m023/generalworkbench.do?method=showPage");
locationMap.put("UK_SUBMMIT", "Submit");
locationMap.put("JP_URL", JP_URL);
locationMap.put("JP_USERID", "tester_001");
locationMap.put("JP_PSW", "welcome1");
locationMap.put("JP_MCODE", "/safelogin/Login?handler=SAFEGetLogin&locale=en&SAFEGoto=http://dev.hkg.swissbank.com:18080/JTI/1/OrderBookFEWeb/m038/generalworkbench.do?method=showPage");
locationMap.put("JP_SUBMMIT", "Submit22");
locationMap.put("IT_URL", IT_URL);
locationMap.put("IT_USERID", "it_ca_005");
locationMap.put("IT_PSW", "welcome1");
locationMap.put("IT_MCODE", "/safe-login/Login?handler=SAFELogin&locale=de_DE&SAFEGoto=http://dev.hkg.swissbank.com:18080/JTI/1/OrderBookFEWeb/m033/generalworkbench.do?method=showPage");
locationMap.put("IT_SUBMMIT", "//input[@value='Login' and @type='submit']");
locationMap.put("FR_URL", FR_URL);
locationMap.put("FR_USERID", "fr_ca_002");
locationMap.put("FR_PSW", "welcome1");
locationMap.put("FR_MCODE", "/safe-login/Login?handler=SAFELogin&locale=de_DE&SAFEGoto=http://dev.hkg.swissbank.com:18080/JTI/1/OrderBookFEWeb/m022/generalworkbench.do?method=showPage");
locationMap.put("FR_SUBMMIT", "//input[@value='Login' and @type='submit']");
locationMap.put("MC_URL", MC_URL);
locationMap.put("MC_USERID", "mc_ca_001");
locationMap.put("MC_PSW", "welcome1");
locationMap.put("MC_MCODE", "/safelogin/Login?handler=SAFEGetLogin&locale=en&SAFEGoto=http://dev.hkg.swissbank.com:18080/JTI/1/OrderBookFEWeb/m042/generalworkbench.do?method=showPage");
locationMap.put("MC_SUBMMIT", "");
}
public void setUp(String location) throws Exception {
this.setUp(locationMap.get(location+"_URL"), browserString);
if (!isSeleniumStart) {
selenium.start();
selenium.open(locationMap.get(location+"_MCODE"));
selenium.waitForPageToLoad("30000");
// Login
selenium.type("SAFEUserID", locationMap.get(location+"_USERID"));
selenium.type("SAFEUserPassword", locationMap.get(location+"_PSW"));
selenium.click(locationMap.get(location+"_SUBMMIT"));
selenium.waitForPageToLoad("30000");
isSeleniumStart = true;
}
}
public void assertNotFoundTable(String locator) {
try {
selenium.getTable(locator);
assertTrue("Should not found:" + locator, false);
} catch (SeleniumException ex) {
assertTrue(ex.getMessage().indexOf(locator + " not found") < 0);
return;
}
}
}