WebSeleniumBaseTestCase

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;
  }
 }
 
 
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值