|
5测试积点
本帖最后由 yk718 于 2014-8-20 15:14 编辑
我想实现从数据库读取数据,读取后做相应操作。
但是每一个操作又可能失败,如元素未找到就失败了,失败后我想程序继续执行读取下一条数据,并继续执行操作。
目前情况是,如果中间有元素未找到,就停在那里了不继续往下执行了!!
- public void read(String url,String database,String table) throws SQLException{
- con=DriverManager.getConnection("jdbc:mysql://192.168.5.155:3306/"+database+"","root","123456");
- Statement statement =con.createStatement();
- Statement statement1 =con.createStatement();
- ResultSet result=statement.executeQuery("SELECT * FROM "+table+"");
- while(result.next()){
- String Step=Integer.toString(result.getInt("Step"));
- String KeyWord=result.getString("KeyWord");
- String Data=result.getString("Data");
- String Object=result.getString("Object");
- String Object_by=Object.split(";")[0].toString();
- String Object_Desc=Object.split(";")[1].toString();
- System.out.println("Step:"+Step);
-
- //******步骤关键字为input*******
- if(KeyWord.equals("Input")){
- //**对象为id
- if(Object_by.equals("id")){
- driver.findElement(By.id(Object_Desc)).sendKeys(Data);}
- //**对象为xpath
- else if(Object_by.equals("xpath")){
- driver.findElement(By.xpath(Object_Desc)).sendKeys(Data);
- }
- }
- //*******步骤关键字为Click*********
- else if(KeyWord.equals("Click")){
- //**对象为id
- if(Object_by.equals("id")){
- driver.findElement(By.id(Object_Desc)).click();
- }
- //**对象为xpath
- else if(Object_by.equals("xpath")){
- driver.findElement(By.xpath(Object_Desc)).click();
- }
- }
复制代码 |
|