CcwpNewOrder_xiaomi
2016-03-18 10:25
316 查看
package Ccwp;
//import java.awt.List;
import java.util.ArrayList;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class CcwpNewOrder_xiaomi {
/*public static void setMaxScroll(WebDriver driver){
try {
JavascriptExecutor jse=(JavascriptExecutor) driver;
jse.executeScript("scroll(0,953)",null);
} catch (Exception e) {
e.printStackTrace();
}
}*/
//document.body.scrollTop
/*public static void setScroll(WebDriver driver,int height){
try {
String setscroll = "document.documentElement.scrollTop=" + height;
JavascriptExecutor jse=(JavascriptExecutor) driver;
System.out.println("++++++");
jse.executeScript(setscroll,null);
System.out.println("=========");
} catch (Exception e) {
System.out.println("Fail to set the scroll.");
}
} */
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","E:\\autotest\\chromedriver_win3224\\chromedriver.exe");
//System.setProperty("webdriver.chrome.driver","E:\\GoogleChrome39/GoogleChrome39/GoogleChromePortable.exe");
WebDriver driver1=new ChromeDriver();
JavascriptExecutor jse=(JavascriptExecutor) driver1;
Navigation navigation1=driver1.navigate();
navigation1.to("http://ccwp.sit.sf-express.com/service/setLogin?phone=13692212840&openId=2.0%3AoH6SdAHaDltBmW4csZs3%2FjVdCqI%3D&channel=2");
try{Thread.sleep(4000);
}catch(InterruptedException e){e.printStackTrace();}
navigation1.to("http://ccwp.sit.sf-express.com/page/xiaomi/index.html");
try{Thread.sleep(3000);
}catch(InterruptedException e){e.printStackTrace();}
driver1.manage().window().maximize();
try{Thread.sleep(1000);
}catch(InterruptedException e){e.printStackTrace();}
WebElement mailstuff=driver1.findElement(By.xpath("//*[@id='wrapper']/section[1]/ul/li[2]/a/h3"));
mailstuff.click();
try{Thread.sleep(2000);
}catch(InterruptedException e){e.printStackTrace();}
WebElement recev_info=driver1.findElement(By.xpath("//*[@id='selectSentHint']"));
recev_info.click();
try{Thread.sleep(4000);
}catch(InterruptedException e){e.printStackTrace();}
//选择收件人
WebElement select_receiv=driver1.findElement(By.xpath("/html/body/section[1]/form/ul/p/li[2]/div/div[1]/div/a/i"));
select_receiv.click();
try{Thread.sleep(3000);
}catch(InterruptedException e){e.printStackTrace();}
WebElement weight=driver1.findElement(By.xpath("//*[@id='wrapper']/section[3]/form/ul/li[5]/div/div[2]/div/a[2]"));
weight.click();
CharSequence[] cs= new CharSequence[1];
cs[0] = "2016年货";
WebElement stuff_name=driver1.findElement(By.xpath("//*[@id='depositum']"));
stuff_name.sendKeys(cs);
CharSequence[] bj= new CharSequence[1];
bj[0] = "1000";
WebElement bao_jia=driver1.findElement(By.xpath("//*[@id='insuredAmount']"));
bao_jia.sendKeys(bj);
CharSequence[] nt= new CharSequence[1];
nt[0] = "易碎物品,小心取放";
WebElement note=driver1.findElement(By.xpath("//*[@id='orderRemark']"));
note.sendKeys(nt);
WebElement note_plus=driver1.findElement(By.xpath("//*[@id='climbStairs']"));
note_plus.click();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement target=driver1.findElement(By.xpath("//*[@id='orderConfirmBut']"));
ArrayList<WebElement> o=new ArrayList<WebElement>();
o.add(target);
jse.executeScript("arguments[0].scrollIntoView();", o.get(0));
//executeAsyncScript("arguments[0].scrollIntoView();",driver1.findElement(By.xpath("//*[@id='orderConfirmBut']")));
//setMaxScroll(driver1);
//setScroll(driver1,1000);
try{Thread.sleep(6000);
}catch(InterruptedException e){e.printStackTrace();}
// String js="var q=document.documentElement.scrollTop=10000";
//((JavascriptExecutor)driver1).executeScript("js");
//((JavascriptExecutor) driver1).executeScript(js);
//driver1.executeScript(js);
//WebElement agree_select=driver1.findElement(By.xpath("//*[@id='makeSure']"));
WebElement agree_select=driver1.findElement(By.id("makeSure"));
agree_select.click();
WebElement conf_order=driver1.findElement(By.xpath("//*[@id='orderConfirmBut']"));
conf_order.click();
try{Thread.sleep(5000);
}catch(InterruptedException e){e.printStackTrace();}
String currenturl=driver1.getCurrentUrl();
System.out.println(currenturl);
String wenzi="{%22code%22:%22200%22";
if(currenturl.contains(wenzi))
System.out.println("小米寄件活动成功!");
else
System.out.println("小米寄件活动失败!");
driver1.quit();
}
}
//import java.awt.List;
import java.util.ArrayList;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class CcwpNewOrder_xiaomi {
/*public static void setMaxScroll(WebDriver driver){
try {
JavascriptExecutor jse=(JavascriptExecutor) driver;
jse.executeScript("scroll(0,953)",null);
} catch (Exception e) {
e.printStackTrace();
}
}*/
//document.body.scrollTop
/*public static void setScroll(WebDriver driver,int height){
try {
String setscroll = "document.documentElement.scrollTop=" + height;
JavascriptExecutor jse=(JavascriptExecutor) driver;
System.out.println("++++++");
jse.executeScript(setscroll,null);
System.out.println("=========");
} catch (Exception e) {
System.out.println("Fail to set the scroll.");
}
} */
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","E:\\autotest\\chromedriver_win3224\\chromedriver.exe");
//System.setProperty("webdriver.chrome.driver","E:\\GoogleChrome39/GoogleChrome39/GoogleChromePortable.exe");
WebDriver driver1=new ChromeDriver();
JavascriptExecutor jse=(JavascriptExecutor) driver1;
Navigation navigation1=driver1.navigate();
navigation1.to("http://ccwp.sit.sf-express.com/service/setLogin?phone=13692212840&openId=2.0%3AoH6SdAHaDltBmW4csZs3%2FjVdCqI%3D&channel=2");
try{Thread.sleep(4000);
}catch(InterruptedException e){e.printStackTrace();}
navigation1.to("http://ccwp.sit.sf-express.com/page/xiaomi/index.html");
try{Thread.sleep(3000);
}catch(InterruptedException e){e.printStackTrace();}
driver1.manage().window().maximize();
try{Thread.sleep(1000);
}catch(InterruptedException e){e.printStackTrace();}
WebElement mailstuff=driver1.findElement(By.xpath("//*[@id='wrapper']/section[1]/ul/li[2]/a/h3"));
mailstuff.click();
try{Thread.sleep(2000);
}catch(InterruptedException e){e.printStackTrace();}
WebElement recev_info=driver1.findElement(By.xpath("//*[@id='selectSentHint']"));
recev_info.click();
try{Thread.sleep(4000);
}catch(InterruptedException e){e.printStackTrace();}
//选择收件人
WebElement select_receiv=driver1.findElement(By.xpath("/html/body/section[1]/form/ul/p/li[2]/div/div[1]/div/a/i"));
select_receiv.click();
try{Thread.sleep(3000);
}catch(InterruptedException e){e.printStackTrace();}
WebElement weight=driver1.findElement(By.xpath("//*[@id='wrapper']/section[3]/form/ul/li[5]/div/div[2]/div/a[2]"));
weight.click();
CharSequence[] cs= new CharSequence[1];
cs[0] = "2016年货";
WebElement stuff_name=driver1.findElement(By.xpath("//*[@id='depositum']"));
stuff_name.sendKeys(cs);
CharSequence[] bj= new CharSequence[1];
bj[0] = "1000";
WebElement bao_jia=driver1.findElement(By.xpath("//*[@id='insuredAmount']"));
bao_jia.sendKeys(bj);
CharSequence[] nt= new CharSequence[1];
nt[0] = "易碎物品,小心取放";
WebElement note=driver1.findElement(By.xpath("//*[@id='orderRemark']"));
note.sendKeys(nt);
WebElement note_plus=driver1.findElement(By.xpath("//*[@id='climbStairs']"));
note_plus.click();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement target=driver1.findElement(By.xpath("//*[@id='orderConfirmBut']"));
ArrayList<WebElement> o=new ArrayList<WebElement>();
o.add(target);
jse.executeScript("arguments[0].scrollIntoView();", o.get(0));
//executeAsyncScript("arguments[0].scrollIntoView();",driver1.findElement(By.xpath("//*[@id='orderConfirmBut']")));
//setMaxScroll(driver1);
//setScroll(driver1,1000);
try{Thread.sleep(6000);
}catch(InterruptedException e){e.printStackTrace();}
// String js="var q=document.documentElement.scrollTop=10000";
//((JavascriptExecutor)driver1).executeScript("js");
//((JavascriptExecutor) driver1).executeScript(js);
//driver1.executeScript(js);
//WebElement agree_select=driver1.findElement(By.xpath("//*[@id='makeSure']"));
WebElement agree_select=driver1.findElement(By.id("makeSure"));
agree_select.click();
WebElement conf_order=driver1.findElement(By.xpath("//*[@id='orderConfirmBut']"));
conf_order.click();
try{Thread.sleep(5000);
}catch(InterruptedException e){e.printStackTrace();}
String currenturl=driver1.getCurrentUrl();
System.out.println(currenturl);
String wenzi="{%22code%22:%22200%22";
if(currenturl.contains(wenzi))
System.out.println("小米寄件活动成功!");
else
System.out.println("小米寄件活动失败!");
driver1.quit();
}
}
相关文章推荐
- cordova插件:inappbrowser
- tomcat增加内存
- (C)do{...}while(0);的用法及意义
- Linux并发(线程特征)
- 12_Bitmap的加载和Cache
- cordova插件:inappbrowser
- 上传app到appstore遇到的问题
- composer 的安装问题
- 关于Spring4中validation的使用
- Linux安装过程
- android在代码中修改view的布局
- iOS下的实际网络连接状态检测:RealReachability
- CcwpAlipayScope
- 局域网内,如何使用命令行关闭别人的电脑
- iOS:iOS开发系列–打造自己的“美图秀秀”(上)
- Oracle 获取当前日期及日期格式
- Linux命令之umask
- FileInfo和DirectoryInfo
- 【项目经验】——考试倒计时
- 关于 shell到 linux服务器断掉进程的解决办法