亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium下載百度音樂并驗證
作者:網絡轉載 發布時間:[ 2014/9/17 13:59:00 ] 推薦標簽:開源軟件測試 性能測試

package baidu;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class selenium  {
public static void snapshot(TakesScreenshot drivername, String filename)
{
// this method will take screen shot ,require two parameters ,one is driver name, another is file name
File scrFile = drivername.getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
try {
System.out.println("save snapshot path is:E:/"+filename);
FileUtils.copyFile(scrFile, new File("E:\"+filename));
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Can't save screenshot");
e.printStackTrace();
}
finally
{
System.out.println("screen shot finished");
}
}
public static void main (String [] args) throws InterruptedException
{
String URL="http://61.135.169.105/";
//avoid Chrome warnning message like "unsupported command-line flag --ignore-certificate-errors. "
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type");
System.setProperty("webdriver.chrome.driver", "D:\selenium\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
driver.get(URL);
//max size the browser
driver.manage().window().maximize();
/*
Navigation navigation = driver.navigate();
navigation.to(URL);*/
Thread.sleep(2000);
snapshot((TakesScreenshot)driver,"open_baidu.png");
//WebElement reg=driver.findElement(By.name("tj_reg"));
//reg.click();
//    WebElement keyWord = driver.findElement(By.id("kw1"));
//find the element
WebElement keyWord = driver.findElement(By.xpath("//input[@id='kw1']"));
keyWord.clear();
//send key words
keyWord.sendKeys("小蘋果");
Thread.sleep(3000);
snapshot((TakesScreenshot)driver,"input_keyWord.png");
WebElement submit = driver.findElement(By.id("su1"));
System.out.println(submit.getLocation());
submit.click();
//System.out.println(driver.getWindowHandle());
Thread.sleep(5000);
WebElement se=driver.findElement(By.xpath("//*[@id="2"]/div[1]/div[2]/table/tbody/tr/td[5]/span/a")) ;
Actions action = new Actions(driver);
action.clickAndHold(se);
action.sendKeys(Keys.DOWN);
Thread.sleep(5000);
List<WebElement> elementList = driver.findElements(By.tagName("herf"));
for(WebElement e:elementList)
{
System.out.print("-->"+e.getText());
}
//se.click();
// System.out.println(driver.getPageSource());
//  System.out.println(pageSource);
//WebElement link =driver.findElement(By.xpath(SELENIUM_LINK));
WebElement link =driver.findElement(By.xpath("//*[@id="2"]/div[1]/div[2]/table/tbody/tr/td[5]/span/a"));//By.xpath("//*[@id="1"]/h3/a"));     //*[@id="1"]/h3/a
link.click();
Thread.sleep(5000);
driver.switchTo().window(driver.getWindowHandles().toArray(new String[0])[1]);
Thread.sleep(5000);
WebElement down =driver.findElement(By.xpath("//*[@id="128"]"));//<i class="icon btn-icon-download-small"></i>
Thread.sleep(5000);
down.click();
snapshot((TakesScreenshot)driver,"down_m.png");
//get page title
System.out.println(driver.getTitle());
Thread.sleep(5000);
WebElement userName=driver.findElement(By.id("TANGRAM__PSP_8__userName"));
WebElement password=driver.findElement(By.id("TANGRAM__PSP_8__password"));
WebElement login=driver.findElement(By.id("TANGRAM__PSP_8__submit"));
Thread.sleep(5000);
userName.sendKeys("QAtest");//your baidu userName
password.sendKeys("mypassword");//your baidu password
login.submit();
//     navigation.back();
snapshot((TakesScreenshot)driver,"open_bake.png");
System.out.println(driver.getTitle()+" "+driver.getCurrentUrl());
Thread.sleep(50000);
File file=new File("C:\Users\Young\Downloads\小蘋果.mp3");
if(file.exists())
{
System.out.println("PASS");
}
else
{
System.out.println("FAIL");
}
driver.quit();
}
}
  如果出現:unsupported command-line flag --ignore-certificate-errors.
  //avoid Chrome warnning message like "unsupported command-line flag --ignore-certificate-errors. "
  ChromeOptions options = new ChromeOptions();
  options.addArguments("--test-type");
  System.setProperty("webdriver.chrome.driver", "D:\selenium\chromedriver.exe");
  WebDriver driver = new ChromeDriver(options);

軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 天天躁日日躁狠狠躁黑人躁 | 亚洲乱码尤物193yw在线播放 | 视频网站黄 | 欧美专区日韩 | 久久精品国产欧美成人 | 日韩伦理剧 | 草草草在线 | 国产高清日韩 | 一区二区不卡不卡一卡 | 国产91免费| 免费在线观看黄网站 | 日韩不卡一级毛片免费 | 亚洲精品午夜级久久久久 | 宅男色影院 | 人人狠人人透人人爱 | 午夜高清福利 | 可以免费观看的黄色网址 | 久久综合五月天 | 免费一级特黄特色大片在线 | 视频色www永久免费 视频区小说区图片区激情 视频免费1区二区三区 | 久久亚洲国产精品一区二区 | 天天搞夜夜 | 天天躁日日躁成人字幕aⅴ 天天在线欧美精品免费看 天天影视涩香欲综合网 | 亚洲国产日韩欧美综合久久 | 欧美日韩专区 | 在线观看视频色 | 99ri精品视频在线观看播放 | 日日夜夜亚洲 | 欧美一级黄色影院 | 日本免费一二区视频 | 日本漫画工囗全彩内番怀孕 | 国产高清在线观看麻豆 | 亚洲影院在线 | 中文字幕精品视频在线观 | 午夜a爱| 成年男女男免费视频网站不卡 | 亚州一级毛片在线 | 欧美成人高清乱码 | 一级做a爱过程免费观看 | 亚洲欧美人成综合在线最新 | 一级片黄色免费 |