在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Python/ 捕捉屏幕截圖
log4j日志
Selenium IDE測(cè)試創(chuàng)建
Selenium - IDE模式匹配
Selenium教程
多瀏覽器測(cè)試
Selenium IDE下載
Selenium用戶擴(kuò)展
鍵盤操作
捕捉屏幕截圖
Selenium網(wǎng)格
Selenium TestNG
Selenium定位器
查找所有鏈接
Selenium測(cè)試設(shè)計(jì)技術(shù)
鼠標(biāo)操作
下拉框交互
Selenium IDE驗(yàn)證點(diǎn)
Selenium IDE- 不同的瀏覽器
Selenium RC
多選擇操作
復(fù)選框交互
單選按鈕互動(dòng)
捕捉視頻
拖放
Selenium IDE 測(cè)試
Synchronization 同步
異常處理
Selenium 環(huán)境安裝設(shè)置
Selenium概述
用戶交互
Selenium Webdriver
Selenium IDE
Selenium頁(yè)面對(duì)象模型
Selenium IDE 工具特點(diǎn)
使用Excel數(shù)據(jù)驅(qū)動(dòng)
Selenium - Selenese命令

捕捉屏幕截圖

捕捉屏幕截圖

截圖捕獲功能可以幫助我們?cè)谛枰谶\(yùn)行時(shí)抓取截圖,在特別是當(dāng)故障發(fā)生。隨著截圖的幫助和日志信息,我們將能夠更好地分析結(jié)果

截圖是本地執(zhí)行和Selenium 網(wǎng)格(遠(yuǎn)程)處決配置不同。讓我們來(lái)看看他們每一個(gè)例子

本地主機(jī)執(zhí)行

在下面的例子中,我們將計(jì)算百分比之后的截圖。請(qǐng)確保給一個(gè)有效的路徑,用以保存屏幕截圖。

import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class webdriverdemo
{
  public static void main(String[] args) throws IOException
  {
	WebDriver driver = new FirefoxDriver();

    //Puts a Implicit wait, Will wait for 10 seconds before throwing exception
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //Launch website
	driver.navigate().to("http://www.calculator.net/");
	
	//Maximize the browser
	driver.manage().window().maximize();

    // Click on Math Calculators
	driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click();
  
    // Click on Percent Calculators
	driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click();

	// Enter value 10 in the first number of the percent Calculator
    driver.findElement(By.id("cpar1")).sendKeys("10");

    // Enter value 50 in the second number of the percent Calculator
    driver.findElement(By.id("cpar2")).sendKeys("50");
    
    // Click Calculate Button
    driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click();

    // Get the Result Text based on its xpath
    String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText();
    
    File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
	
	FileUtils.copyFile(screenshot, new File("D:screenshotsscreenshots1.jpg"));	
	
	//Print a Log In message to the screen
    System.out.println(" The Result is " + result);
    
	//Close the Browser.
    driver.close();    
  }
}

輸出

在執(zhí)行這個(gè)腳本,截圖保存在“D:screenshots”文件夾中名為'screenshots1.jpg“,如下圖所示。

selenium_ide_172

Selenium網(wǎng)格- 捕捉屏幕截圖

當(dāng)Selenium網(wǎng)格工作,我們應(yīng)該確保從遠(yuǎn)程系統(tǒng)采取正確的截圖。我們將充分利用增強(qiáng)的驅(qū)動(dòng)程序。

例子

我們將連接到集線器Firefox的節(jié)點(diǎn)上執(zhí)行該腳本。更多關(guān)于配置集線器和節(jié)點(diǎn),請(qǐng)參閱Selenium網(wǎng)格章節(jié)。

package TestNG;

import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.TakesScreenshot;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.io.File;
import java.net.URL;
import java.net上一篇:Selenium IDE下一篇:多瀏覽器測(cè)試