我正在尝试在Selenium Webdriver中设置一个对象存储库,以确保对象的未来更改不会影响我的脚本。
答案 0 :(得分:2)
从我的角度来看PageObjects是要走的路。
那很简单!
答案 1 :(得分:0)
答案 2 :(得分:0)
try{
while(loc_index<=loc_type.size()-1){
// System.out.println("1sy");
while(loc_val_index<=loc_val.size()){
while(obj_index<=obj_value.size()-1){
String loc_data = loc_type.get(loc_index);
if(loc_data.equals("name")){
WebElement element = driver.findElement(By.name(loc_val.get(loc_val_index)));
if (element!=null){
try {
element.sendKeys(obj_value.get(obj_index)); } catch (Exception e){}
obj_index++;}}else if(loc_data.equals("xpath")){
WebElement element = driver.findElement(By.xpath(loc_val.get(loc_val_index)));
if (element!=null){
element.sendKeys(obj_value.get(obj_index));
Log("Data Entered");
obj_index++;}}
else if(loc_data.equals("id")){
try{
WebElement element = driver.findElement(By.id(loc_val.get(loc_val_index)));
if (element!=null){
element.sendKeys(obj_value.get(obj_index));
obj_index++;}} catch (Exception e) {}}
break;}
loc_val_index++;
break;}
loc_index++;
}
}catch (Exception e){}
finally{
obj_index=0;
loc_index=0;
loc_val_index=0;
}