Page tree
Skip to end of metadata
Go to start of metadata

void capture(Line)

void capture()

Supported in iOS Supported in Android

Description

Enables you to capture a screenshot of the device in a given time. The captured screenshot will be a full resolution and quality image of the device.

Parameters

  • Optional parameter:
    • Line: Name of the step on the report

Usage

Command returns a string which represent the path to the image location during runtime. This image will be deleted once GenerateReport is executed and will move to the report folder.

Parameters:

  • Optional parameter:
    • Line: Name of the step on the report

    On the generated report, the step with the following capture command will be added as a separate command with screenshot as shown below

Example

Scenario: The following code shows how to use a captured screenshot during runtime. We will copy the screenshot that gets generated into the desired folder. Afterwards, we can use it as per your business requirements.

package testCapture;
//package <set your test package>;;
import static java.nio.file.StandardCopyOption.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Files;
import com.experitest.client.*;
import org.junit.*;
/**
 *
 *
*/
public class testCapture {
	private String host = "localhost";
    private int port = 8889;
    private String projectBaseDirectory = "C:\\Users\\user_12\\workspace\\project3";
    protected Client client = null;
    @Before
    public void setUp(){
        client = new Client(host, port, true);
        client.setProjectBaseDirectory(projectBaseDirectory);
        client.setReporter("xml", "reports", "Untitled");
    }
    @Test
    public void testCapture123() throws IOException{
        client.setDevice("adb:samsung SM-N7505");
        String str0 = client.capture("Capture");
        client.sleep(5000);
        Path psource =new File(str0).toPath();
        Path pdest =new File("C:\\Temp\\"+"Device reflection at the beginning of test.png").toPath();
		Files.copy(psource,pdest,REPLACE_EXISTING);
        }

    @After
    public void tearDown(){
        client.generateReport(true);
    }
}
  • No labels