How to use OccurrenceMatchingOptions class of io.appium.java_client.imagecomparison package

Best io.appium code snippet using io.appium.java_client.imagecomparison.OccurrenceMatchingOptions

ComparesImages.java

Source:ComparesImages.java Github

copy

Full Screen

...17import static io.appium.java_client.MobileCommand.compareImagesCommand;18import io.appium.java_client.imagecomparison.ComparisonMode;19import io.appium.java_client.imagecomparison.FeaturesMatchingOptions;20import io.appium.java_client.imagecomparison.FeaturesMatchingResult;21import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;22import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;23import io.appium.java_client.imagecomparison.SimilarityMatchingOptions;24import io.appium.java_client.imagecomparison.SimilarityMatchingResult;25import org.apache.commons.codec.binary.Base64;26import org.apache.commons.io.FileUtils;27import java.io.File;28import java.io.IOException;29import java.util.Map;30import javax.annotation.Nullable;31public interface ComparesImages extends ExecutesMethod {32 /**33 * Performs images matching by features with default options. Read34 * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html35 * for more details on this topic.36 *37 * @param base64image1 base64-encoded representation of the first image38 * @param base64Image2 base64-encoded representation of the second image39 * @return The matching result.40 */41 default FeaturesMatchingResult matchImagesFeatures(byte[] base64image1, byte[] base64Image2) {42 return matchImagesFeatures(base64image1, base64Image2, null);43 }44 /**45 * Performs images matching by features. Read46 * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html47 * for more details on this topic.48 *49 * @param base64image1 base64-encoded representation of the first image50 * @param base64Image2 base64-encoded representation of the second image51 * @param options comparison options52 * @return The matching result. The configuration of fields in the result depends on comparison options.53 */54 default FeaturesMatchingResult matchImagesFeatures(byte[] base64image1, byte[] base64Image2,55 @Nullable FeaturesMatchingOptions options) {56 Object response = CommandExecutionHelper.execute(this,57 compareImagesCommand(ComparisonMode.MATCH_FEATURES, base64image1, base64Image2, options));58 //noinspection unchecked59 return new FeaturesMatchingResult((Map<String, Object>) response);60 }61 /**62 * Performs images matching by features with default options. Read63 * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html64 * for more details on this topic.65 *66 * @param image1 The location of the first image67 * @param image2 The location of the second image68 * @return The matching result.69 */70 default FeaturesMatchingResult matchImagesFeatures(File image1, File image2) throws IOException {71 return matchImagesFeatures(image1, image2, null);72 }73 /**74 * Performs images matching by features. Read75 * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html76 * for more details on this topic.77 *78 * @param image1 The location of the first image79 * @param image2 The location of the second image80 * @param options comparison options81 * @return The matching result. The configuration of fields in the result depends on comparison options.82 */83 default FeaturesMatchingResult matchImagesFeatures(File image1, File image2,84 @Nullable FeaturesMatchingOptions options) throws IOException {85 return matchImagesFeatures(Base64.encodeBase64(FileUtils.readFileToByteArray(image1)),86 Base64.encodeBase64(FileUtils.readFileToByteArray(image2)), options);87 }88 /**89 * Performs images matching by template to find possible occurrence of the partial image90 * in the full image with default options. Read91 * https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html92 * for more details on this topic.93 *94 * @param fullImage base64-encoded representation of the full image95 * @param partialImage base64-encoded representation of the partial image96 * @return The matching result.97 */98 default OccurrenceMatchingResult findImageOccurrence(byte[] fullImage, byte[] partialImage) {99 return findImageOccurrence(fullImage, partialImage, null);100 }101 /**102 * Performs images matching by template to find possible occurrence of the partial image103 * in the full image. Read104 * https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html105 * for more details on this topic.106 *107 * @param fullImage base64-encoded representation of the full image108 * @param partialImage base64-encoded representation of the partial image109 * @param options comparison options110 * @return The matching result. The configuration of fields in the result depends on comparison options.111 */112 default OccurrenceMatchingResult findImageOccurrence(byte[] fullImage, byte[] partialImage,113 @Nullable OccurrenceMatchingOptions options) {114 Object response = CommandExecutionHelper.execute(this,115 compareImagesCommand(ComparisonMode.MATCH_TEMPLATE, fullImage, partialImage, options));116 //noinspection unchecked117 return new OccurrenceMatchingResult((Map<String, Object>) response);118 }119 /**120 * Performs images matching by template to find possible occurrence of the partial image121 * in the full image with default options. Read122 * https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html123 * for more details on this topic.124 *125 * @param fullImage The location of the full image126 * @param partialImage The location of the partial image127 * @return The matching result. The configuration of fields in the result depends on comparison options.128 */129 default OccurrenceMatchingResult findImageOccurrence(File fullImage, File partialImage) throws IOException {130 return findImageOccurrence(fullImage, partialImage, null);131 }132 /**133 * Performs images matching by template to find possible occurrence of the partial image134 * in the full image. Read135 * https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html136 * for more details on this topic.137 *138 * @param fullImage The location of the full image139 * @param partialImage The location of the partial image140 * @param options comparison options141 * @return The matching result. The configuration of fields in the result depends on comparison options.142 */143 default OccurrenceMatchingResult findImageOccurrence(File fullImage, File partialImage,144 @Nullable OccurrenceMatchingOptions options)145 throws IOException {146 return findImageOccurrence(Base64.encodeBase64(FileUtils.readFileToByteArray(fullImage)),147 Base64.encodeBase64(FileUtils.readFileToByteArray(partialImage)), options);148 }149 /**150 * Performs images matching to calculate the similarity score between them151 * with default options. The flow there is similar to the one used in152 * {@link #findImageOccurrence(byte[], byte[], OccurrenceMatchingOptions)},153 * but it is mandatory that both images are of equal size.154 *155 * @param base64image1 base64-encoded representation of the first image156 * @param base64Image2 base64-encoded representation of the second image157 * @return Matching result. The configuration of fields in the result depends on comparison options.158 */159 default SimilarityMatchingResult getImagesSimilarity(byte[] base64image1, byte[] base64Image2) {160 return getImagesSimilarity(base64image1, base64Image2, null);161 }162 /**163 * Performs images matching to calculate the similarity score between them.164 * The flow there is similar to the one used in165 * {@link #findImageOccurrence(byte[], byte[], OccurrenceMatchingOptions)},166 * but it is mandatory that both images are of equal size.167 *168 * @param base64image1 base64-encoded representation of the first image169 * @param base64Image2 base64-encoded representation of the second image170 * @param options comparison options171 * @return Matching result. The configuration of fields in the result depends on comparison options.172 */173 default SimilarityMatchingResult getImagesSimilarity(byte[] base64image1, byte[] base64Image2,174 @Nullable SimilarityMatchingOptions options) {175 Object response = CommandExecutionHelper.execute(this,176 compareImagesCommand(ComparisonMode.GET_SIMILARITY, base64image1, base64Image2, options));177 //noinspection unchecked178 return new SimilarityMatchingResult((Map<String, Object>) response);179 }180 /**181 * Performs images matching to calculate the similarity score between them182 * with default options. The flow there is similar to the one used in183 * {@link #findImageOccurrence(byte[], byte[], OccurrenceMatchingOptions)},184 * but it is mandatory that both images are of equal size.185 *186 * @param image1 The location of the full image187 * @param image2 The location of the partial image188 * @return Matching result. The configuration of fields in the result depends on comparison options.189 */190 default SimilarityMatchingResult getImagesSimilarity(File image1, File image2) throws IOException {191 return getImagesSimilarity(image1, image2, null);192 }193 /**194 * Performs images matching to calculate the similarity score between them.195 * The flow there is similar to the one used in196 * {@link #findImageOccurrence(byte[], byte[], OccurrenceMatchingOptions)},197 * but it is mandatory that both images are of equal size.198 *199 * @param image1 The location of the full image200 * @param image2 The location of the partial image201 * @param options comparison options202 * @return Matching result. The configuration of fields in the result depends on comparison options.203 */204 default SimilarityMatchingResult getImagesSimilarity(File image1, File image2,205 @Nullable SimilarityMatchingOptions options)206 throws IOException {207 return getImagesSimilarity(Base64.encodeBase64(FileUtils.readFileToByteArray(image1)),208 Base64.encodeBase64(FileUtils.readFileToByteArray(image2)), options);209 }210}...

Full Screen

Full Screen

TestMobileApp.java

Source:TestMobileApp.java Github

copy

Full Screen

1package jp.shiftinc.automation.trial;2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.MobileElement;4import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;5import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;6import io.appium.java_client.ios.IOSStartScreenRecordingOptions;7import io.appium.java_client.screenrecording.CanRecordScreen;8import io.qameta.allure.Allure;9import io.qameta.allure.Attachment;10import io.qameta.allure.Feature;11import io.qameta.allure.Step;12import org.junit.jupiter.api.AfterEach;13import org.junit.jupiter.api.BeforeAll;14import org.junit.jupiter.api.TestInstance;15import org.junit.jupiter.params.ParameterizedTest;16import org.junit.jupiter.params.provider.Arguments;17import org.junit.jupiter.params.provider.MethodSource;18import org.openqa.selenium.OutputType;19import org.openqa.selenium.WebElement;20import javax.imageio.ImageIO;21import java.awt.image.BufferedImage;22import java.io.ByteArrayInputStream;23import java.io.ByteArrayOutputStream;24import java.io.File;25import java.io.IOException;26import java.nio.file.Files;27import java.nio.file.Paths;28import java.util.Base64;29import java.util.concurrent.TimeUnit;30import java.util.stream.Stream;31import static org.junit.jupiter.api.Assertions.assertNotNull;32import static org.junit.jupiter.params.provider.Arguments.arguments;33@SuppressWarnings({"SameParameterValue", "FieldCanBeLocal"})34@Feature("Appiumイメージセレクタテスト")35@TestInstance(TestInstance.Lifecycle.PER_CLASS)36class TestMobileApp {37 private AppiumDriver driver;38 private OSBase osInfo;39 @BeforeAll40 void setupClass() {41 }42 @Step("{osName}/イメージセレクタでログイン")43 @ParameterizedTest44 @MethodSource("osMartix")45 void imageSelectorTest(String osName) throws IOException, InterruptedException {46 setup(osName);47 // イメージセレクタ48 WebElement loginElm = driver.findElementByImage(getReferenceImageB64("racine_sut_login.png"));49 // visualization50 String imageResult = loginElm.getAttribute("visual");51 // Allureにアタッチ(サービス関数経由)52 addAttachment(Base64.getDecoder().decode(imageResult), "image-selector");53 loginElm.click();54 Thread.sleep(20000);55 //addAttachment(driver.getScreenshotAs(OutputType.BYTES),"img1");56 // テンプレートマッチング57 OccurrenceMatchingResult result = templateMatch("original_template.png");58 // Allureにアタッチ(サービス関数経由)59 addAttachment(Base64.getDecoder().decode(result.getVisualization()), "template-matched-result");60 assertNotNull(result.getRect());61 }62 Stream<Arguments> osMartix() {63 return Stream.of(64 arguments("ios"),65 arguments("android")66 );67 }68 @AfterEach69 void tearDown() throws IOException {70 if (driver != null) {71 String base64Video = ((CanRecordScreen) driver).stopRecordingScreen();72 String path = String.format("./build/test_%s.mp4",osInfo.osName());73 Files.write(Paths.get(path), Base64.getDecoder().decode(base64Video));74 attachVideo(path);75 driver.closeApp();76 }77 }78 private void setup(String os) {79 osInfo = os.equals("ios")? new IOSBase():new AndroidBase();80 driver = osInfo.driver();81 driver.launchApp();82 driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);83 if (os.equals("ios")) {84 ((IOSBase)osInfo).iosDriver.startRecordingScreen(85 new IOSStartScreenRecordingOptions()86 .withVideoType("libx264")87 .withVideoScale("320:640")88 .withVideoQuality(IOSStartScreenRecordingOptions.VideoQuality.MEDIUM)89 );90 } else {91 ((AndroidBase)osInfo).androidDriver.startRecordingScreen();92 }93 MobileElement loginId = (MobileElement) driver.findElement(osInfo.loginId());94 MobileElement loginPwd = (MobileElement) driver.findElement(osInfo.loginPwd());95 loginId.sendKeys("demo");96 loginPwd.click();97 loginPwd.sendKeys("demo");98 }99 private String getReferenceImageB64(String imageName) throws IOException {100 BufferedImage image = ImageIO.read(new File(osInfo.resourceDir() + imageName));101 ByteArrayOutputStream os = new ByteArrayOutputStream();102 ImageIO.write(image, "png", os);103 return Base64.getEncoder().encodeToString(os.toByteArray());104 }105 private OccurrenceMatchingResult templateMatch(String template) throws IOException {106 return driver107 .findImageOccurrence(108 driver.getScreenshotAs(OutputType.FILE),109 new File(osInfo.resourceDir() + template),110 new OccurrenceMatchingOptions()111 .withThreshold(0.6)112 .withEnabledVisualization());113 }114 private static void addAttachment(byte[] byteArray, String imageName) {115 Allure.addAttachment(imageName, "image/png", new ByteArrayInputStream(byteArray), "png");116 }117 @SuppressWarnings("UnusedReturnValue")118 @Attachment(value = "video",type="video/mp4",fileExtension = "mp4")119 private byte[] attachVideo(String path) throws IOException {120 return getFile(path);121 }122 private byte[] getFile(String fileName) throws IOException {123 File file = new File(fileName);124 return Files.readAllBytes(Paths.get(file.getAbsolutePath()));...

Full Screen

Full Screen

ImagesComparisonTest.java

Source:ImagesComparisonTest.java Github

copy

Full Screen

...22import io.appium.java_client.imagecomparison.FeatureDetector;23import io.appium.java_client.imagecomparison.FeaturesMatchingOptions;24import io.appium.java_client.imagecomparison.FeaturesMatchingResult;25import io.appium.java_client.imagecomparison.MatchingFunction;26import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;27import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;28import io.appium.java_client.imagecomparison.SimilarityMatchingOptions;29import io.appium.java_client.imagecomparison.SimilarityMatchingResult;30import org.apache.commons.codec.binary.Base64;31import org.junit.Test;32import org.openqa.selenium.OutputType;33public class ImagesComparisonTest extends AppIOSTest {34 @Test35 public void verifyFeaturesMatching() {36 byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));37 FeaturesMatchingResult result = driver38 .matchImagesFeatures(screenshot, screenshot, new FeaturesMatchingOptions()39 .withDetectorName(FeatureDetector.ORB)40 .withGoodMatchesFactor(40)41 .withMatchFunc(MatchingFunction.BRUTE_FORCE_HAMMING)42 .withEnabledVisualization());43 assertThat(result.getVisualization().length, is(greaterThan(0)));44 assertThat(result.getCount(), is(greaterThan(0)));45 assertThat(result.getTotalCount(), is(greaterThan(0)));46 assertFalse(result.getPoints1().isEmpty());47 assertNotNull(result.getRect1());48 assertFalse(result.getPoints2().isEmpty());49 assertNotNull(result.getRect2());50 }51 @Test52 public void verifyOccurrencesSearch() {53 byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));54 OccurrenceMatchingResult result = driver55 .findImageOccurrence(screenshot, screenshot, new OccurrenceMatchingOptions()56 .withEnabledVisualization());57 assertThat(result.getVisualization().length, is(greaterThan(0)));58 assertNotNull(result.getRect());59 }60 @Test61 public void verifySimilarityCalculation() {62 byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));63 SimilarityMatchingResult result = driver64 .getImagesSimilarity(screenshot, screenshot, new SimilarityMatchingOptions()65 .withEnabledVisualization());66 assertThat(result.getVisualization().length, is(greaterThan(0)));67 assertThat(result.getScore(), is(greaterThan(0.0)));68 }69}...

Full Screen

Full Screen

RecordingTest.java

Source:RecordingTest.java Github

copy

Full Screen

2import com.wordpress.utils.BaseTest;3import io.appium.java_client.HasSettings;4import io.appium.java_client.Setting;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;7import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;8import io.appium.java_client.ios.IOSDriver;9import org.apache.commons.io.FileUtils;10import org.openqa.selenium.OutputType;11import org.testng.annotations.Test;12import java.io.File;13import java.io.IOException;14import java.nio.file.Paths;15import java.util.Base64;16public class RecordingTest extends BaseTest {17 @Test18 public void iOSScreenRecordTest() throws IOException {19 ((IOSDriver)driver).startRecordingScreen();20 String s = ((IOSDriver) driver).stopRecordingScreen();21 byte[] decode = Base64.getDecoder().decode(s);22 FileUtils.writeByteArrayToFile(new File(23 System.getProperty("user.dir")24 +"/sample.mp4"),25 decode);26 }27 @Test28 public void androidScreenRecordTest() throws IOException, InterruptedException {29 ((AndroidDriver)driver).startRecordingScreen();30 Thread.sleep(10000);31 String s = ((AndroidDriver) driver).stopRecordingScreen();32 byte[] decode = Base64.getDecoder().decode(s);33 FileUtils.writeByteArrayToFile(new File(System.getProperty("user.dir")+"/sample.mp4"),34 decode);35 }36 @Test37 public void testApp() throws IOException {38 //((HasSettings)driver).setSetting(Setting.IMAGE_MATCH_THRESHOLD, "4.0");39 ((AndroidDriver) driver).sendSMS("555-555-5555", "Your message here!");40 ((HasSettings)driver).setSetting(Setting.FIX_IMAGE_TEMPLATE_SIZE, "true");41 ((HasSettings)driver).setSetting(Setting.IMAGE_ELEMENT_TAP_STRATEGY, "touchActions");42 File file = new File("/Users/saikrisv/Desktop/login.png");43 File refImgFile = Paths.get(file.toURI()).toFile();44 File screenshotAs = driver.getScreenshotAs(OutputType.FILE);45 OccurrenceMatchingResult result = driver46 .findImageOccurrence(screenshotAs, new File("/Users/saikrisv/Desktop/login.png") ,47 new OccurrenceMatchingOptions()48 .withEnabledVisualization());49 System.out.println(result.getRect());50 //driver.findElementByImage(s).click();51 }52}

Full Screen

Full Screen

VisulizationTest.java

Source:VisulizationTest.java Github

copy

Full Screen

1package testcases;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;4import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;5import org.apache.commons.codec.binary.Base64;6import org.openqa.selenium.OutputType;7import org.testng.Assert;8import org.testng.annotations.BeforeTest;9import org.testng.annotations.Test;10import utils.ImageUtils;11import java.io.IOException;12import java.net.URISyntaxException;13import java.net.URL;14/**15 * Year: 2018-1916 *17 * @author Prat3ik on 17/01/1918 * @project Image Comparision Appium19 */20public class VisulizationTest extends BaseTest{21 @BeforeTest22 @Override23 public void setUpPage() throws IOException {24 androidDriver = new AndroidDriver(new URL(APPIUM_SERVER_URL), getDesiredCapabilitiesForAndroid());25 }26 @Test27 public void testVisulization() throws IOException, URISyntaxException {28 byte[] fullImage = Base64.encodeBase64(ImageUtils.getBase64ByteFormatOfImage("abstractFullImage.jpg"));29 byte[] partialImage = Base64.encodeBase64(ImageUtils.getBase64ByteFormatOfImage("abstractPartialImage.png"));30 OccurrenceMatchingResult imageOccurrence = androidDriver.findImageOccurrence(fullImage, partialImage, new OccurrenceMatchingOptions()31 .withThreshold(0.1).withEnabledVisualization());32 System.out.println(imageOccurrence.getRect().getDimension());33 System.out.println("X:"+imageOccurrence.getRect().getX());34 System.out.println("Y:"+imageOccurrence.getRect().getY());35 System.out.println("Height:"+imageOccurrence.getRect().getHeight());36 System.out.println("Width:"+imageOccurrence.getRect().getWidth());37 System.out.println(imageOccurrence.getVisualization().length);38 Assert.assertTrue(imageOccurrence.getVisualization().length > 0 , "Partial image is not present!");39 }40}...

Full Screen

Full Screen

ImageButtonTest.java

Source:ImageButtonTest.java Github

copy

Full Screen

1package testcases;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;4import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;5import io.appium.java_client.imagecomparison.SimilarityMatchingResult;6import org.apache.commons.codec.binary.Base64;7import org.openqa.selenium.By;8import org.openqa.selenium.OutputType;9import org.openqa.selenium.WebElement;10import org.testng.Assert;11import org.testng.annotations.BeforeTest;12import org.testng.annotations.Test;13import utils.ImageUtils;14import java.awt.*;15import java.io.File;16import java.io.IOException;17import java.net.URISyntaxException;...

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;2OccurrenceMatchingOptions occurrenceMatchingOptions = new OccurrenceMatchingOptions();3occurrenceMatchingOptions.withEnabled(true);4occurrenceMatchingOptions.withMaxOccurrence(3);5occurrenceMatchingOptions.withMinOccurrence(1);6occurrenceMatchingOptions.withThreshold(0.9);7driver.findElementByImage("path/to/image.png", occurrenceMatchingOptions);8driver.find_element_by_image("path/to/image.png", occurrence_matching_options)9from appium.webdriver.imagecomparison import OccurrenceMatchingOptions10occurrence_matching_options = OccurrenceMatchingOptions()11driver.find_element_by_image("path/to/image.png", occurrence_matching_options)12const { OccurrenceMatchingOptions } = require('appium-image-comparison');13const occurrenceMatchingOptions = new OccurrenceMatchingOptions()14driver.findElementByImage("path/to/image.png", occurrenceMatchingOptions)15using Appium.ImageComparison;16OccurrenceMatchingOptions occurrenceMatchingOptions = new OccurrenceMatchingOptions();17occurrenceMatchingOptions.Enabled = true;18occurrenceMatchingOptions.MaxOccurrence = 3;19occurrenceMatchingOptions.MinOccurrence = 1;20occurrenceMatchingOptions.Threshold = 0.9;21driver.FindElementByImage("path/to/image.png",

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;2import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;3import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;4import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;5import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;6import org.openqa.selenium.By;7import org.openqa.selenium.WebElement;8import org.testng.annotations.Test;9import java.util.List;10import java.util.stream.Collectors;11public class OccurrenceMatchingTest extends BaseTest {12 public void occurrenceMatchingTest() {13 WebElement element = driver.findElement(By.id("io.appium.android.apis:id/occurrence"));14 OccurrenceMatchingOptions occurrenceMatchingOptions = new OccurrenceMatchingOptions();15 occurrenceMatchingOptions.withEnabled(true);16 occurrenceMatchingOptions.withThreshold(0.2);17 occurrenceMatchingOptions.withMaxOccurrence(2);18 occurrenceMatchingOptions.withOccurrenceOrder(OccurrenceMatchingOptions.OccurrenceOrder.FIRST);19 occurrenceMatchingOptions.withElement(element);20 List<OccurrenceMatchingResult> occurrenceMatchingResultList = driver.findImagesOccurrence("occurrence", occurrenceMatchingOptions);21 List<Integer> occurrenceCountList = occurrenceMatchingResultList.stream().map(OccurrenceMatchingResult::getOccurrenceCount).collect(Collectors.toList());22 assert occurrenceCountList.contains(1);23 assert occurrenceCountList.contains(2);24 }25}26from appium import webdriver27from appium.webdriver.common.mobileby import MobileBy28from appium.webdriver.common.imagecomparison import OccurrenceMatchingOptions29desired_caps = {}

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1OccurrenceMatchingOptions occurrenceMatchingOptions = new OccurrenceMatchingOptions();2occurrenceMatchingOptions.withEnabled(true);3occurrenceMatchingOptions.withMaxOccurrence(2);4occurrenceMatchingOptions.withThreshold(0.8);5occurrenceMatchingOptions.withOutputName("occurrence");6occurrenceMatchingOptions.withOutputType("png");7occurrenceMatchingOptions.withOutputDir("/data/local/tmp");8occurrenceMatchingOptions.withRectangles("0,0,100,100");9occurrenceMatchingOptions.withRectangles("0,0,200,200");10occurrenceMatchingOptions.withRectangles("0,0,300,300");11occurrenceMatchingOptions.withRectangles("0,0,400,400");12occurrenceMatchingOptions.withRectangles("0,0,500,500");13occurrenceMatchingOptions.withRectangles("0,0,600,600");14occurrenceMatchingOptions.withRectangles("0,0,700,700");15occurrenceMatchingOptions.withRectangles("0,0,800,800");16occurrenceMatchingOptions.withRectangles("0,0,900,900");17occurrenceMatchingOptions.withRectangles("0,0,1000,1000");18occurrenceMatchingOptions.withRectangles("0,0,1100,1100");19occurrenceMatchingOptions.withRectangles("0,0,1200,1200");20occurrenceMatchingOptions.withRectangles("0,0,1300,1300");21occurrenceMatchingOptions.withRectangles("0,0,1400,1400");22occurrenceMatchingOptions.withRectangles("0,0,1500,1500");23occurrenceMatchingOptions.withRectangles("0,0,1600,1600");24occurrenceMatchingOptions.withRectangles("0,0,1700,1700");25occurrenceMatchingOptions.withRectangles("0,0,1800,1800");26occurrenceMatchingOptions.withRectangles("0,0,1900,1900");27occurrenceMatchingOptions.withRectangles("0,0,2000,2000");28occurrenceMatchingOptions.withRectangles("0,0,2100,2100");29occurrenceMatchingOptions.withRectangles("0,0,2200,2200");30occurrenceMatchingOptions.withRectangles("0,0,2300,2300");31occurrenceMatchingOptions.withRectangles("0,0,2400,2400");

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;2import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;3OccurrenceMatchingOptions occurrenceMatchingOptions = new OccurrenceMatchingOptions();4occurrenceMatchingOptions.withEnabledVisualization();5occurrenceMatchingOptions.withEnabledDebug();6occurrenceMatchingOptions.withEnabledReturnAfterFirstMatch();7OccurrenceMatchingResult occurrenceMatchingResult = driver.findImageOccurrence("image1", occurrenceMatchingOptions);8List<MatchedImageResult> matchedImageResults = occurrenceMatchingResult.getMatchedImageResults();9driver = Appium::Driver.new(opts, true)10occurrence_matching_result = driver.find_image_occurrence('image1', occurrence_matching_options)11const { remote } = require('webdriverio')12const { OccurrenceMatchingOptions, OccurrenceMatchingResult } = require('webdriverio/build/commands/element/findImageOccurrence')13const opts = {14 capabilities: {15 }16}17async function main () {18 const client = await remote(opts)19 const occurrenceMatchingOptions = new OccurrenceMatchingOptions()20 occurrenceMatchingOptions.withEnabledVisualization()21 occurrenceMatchingOptions.withEnabledDebug()

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1OccurrenceMatchingOptions occurrenceMatchingOptions = new OccurrenceMatchingOptions();2occurrenceMatchingOptions.withEnabledVisualization();3occurrenceMatchingOptions.withEnabledDebugging();4occurrenceMatchingOptions.withMaxOccurrence(1);5occurrenceMatchingOptions.withThreshold(0.9);6occurrenceMatchingOptions.withOutputName("output");7occurrenceMatchingOptions.withOutputDir("outputDir");8occurrenceMatchingOptions.withOutputFormat(OutputFormat.PNG);9occurrenceMatchingOptions.withVisualizationColor(Color.RED);10occurrenceMatchingOptions.withVisualizationType(VisualizationType.BOX);11occurrenceMatchingOptions.withVisualizationThickness(5);12occurrenceMatchingOptions.withDebugSensitivity(DebugSensitivity.HIGH);13ImageComparisonResult imageComparisonResult = driver.findImageElement(occurrenceMatchingOptions, "referenceImage");14imageComparisonResult.getScore();15imageComparisonResult.getRect();16imageComparisonResult.getMatchesTemplate();17imageComparisonResult.getVisualization();18TemplateMatchingOptions templateMatchingOptions = new TemplateMatchingOptions();19templateMatchingOptions.withEnabledVisualization();20templateMatchingOptions.withEnabledDebugging();21templateMatchingOptions.withMaxOccurrence(1);22templateMatchingOptions.withThreshold(0.9);23templateMatchingOptions.withOutputName("output");24templateMatchingOptions.withOutputDir("outputDir");25templateMatchingOptions.withOutputFormat(OutputFormat.PNG);26templateMatchingOptions.withVisualizationColor(Color.RED);27templateMatchingOptions.withVisualizationType(VisualizationType.BOX);28templateMatchingOptions.withVisualizationThickness(5);29templateMatchingOptions.withDebugSensitivity(DebugSensitivity.HIGH);30ImageComparisonResult imageComparisonResult = driver.findImageElement(templateMatchingOptions, "referenceImage");31imageComparisonResult.getScore();32imageComparisonResult.getRect();33imageComparisonResult.getMatchesTemplate();34imageComparisonResult.getVisualization();35TemplateMatchingOptions templateMatchingOptions = new TemplateMatchingOptions();36templateMatchingOptions.withEnabledVisualization();37templateMatchingOptions.withEnabledDebugging();38templateMatchingOptions.withMaxOccurrence(1);39templateMatchingOptions.withThreshold(0.9);40templateMatchingOptions.withOutputName("output");41templateMatchingOptions.withOutputDir("outputDir");42templateMatchingOptions.withOutputFormat(OutputFormat.PNG);43templateMatchingOptions.withVisualizationColor(Color.RED);

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1package appium.java;2import java.io.File;3import java.io.IOException;4import java.net.MalformedURLException;5import java.net.URL;6import java.util.concurrent.TimeUnit;7import org.openqa.selenium.By;8import org.openqa.selenium.remote.DesiredCapabilities;9import io.appium.java_client.MobileElement;10import io.appium.java_client.android.AndroidDriver;11import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;12import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;13public class OccurrenceMatchingOptionsDemo {14 public static void main(String[] args) throws MalformedURLException, IOException {15 DesiredCapabilities caps = new DesiredCapabilities();16 caps.setCapability("deviceName", "Pixel_4_Emulator");17 caps.setCapability("platformName", "Android");18 caps.setCapability("appPackage", "com.android.chrome");19 caps.setCapability("appActivity", "com.google.android.apps.chrome.Main");20 caps.setCapability("noReset", true);

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;2import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;3import io.appium.java_client.imagecomparison.OccurrenceMatchingResult.Occurrence;4import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;5import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;6import io.appium.java_client.imagecomparison.OccurrenceMatchingResult.Occurrence;7import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;8import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;9import io.appium.java_client.imagecomparison.OccurrenceMatchingResult.Occurrence;10import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;11import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;12import io.appium.java_client.imagecomparison.OccurrenceMatchingResult.Occurrence;13import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;14import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;15import io.appium.java_client.imagecomparison.OccurrenceMatchingResult.Occurrence;16import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;17import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;18import io.appium.java_client.imagecomparison.OccurrenceMatchingResult.Occurrence;

Full Screen

Full Screen

OccurrenceMatchingOptions

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;2import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;3import io.appium.java_client.imagecomparison.OccurrenceMatchingScore;4import io.appium.java_client.imagecomparison.OccurrenceMatchingSettings;5import io.appium.java_client.imagecomparison.OccurrenceMatchingTemplate;6import io.appium.java_client.imagecomparison.OccurrenceMatchingTemplateSettings;7import io.appium.java_client.imagecomparison.OccurrenceMatchingThreshold;8import io.appium.java_client.imagecomparison.OccurrenceMatchingThresholdSettings;9import io.appium.java_client.imagecomparison.OccurrenceMatchingType;10import io.appium.java_client.imagecomparison.OccurrencePoint;11import io.appium.java_client.imagecomparison.OccurrencePointWithScore;12import io.appium.java_client.imagecomparison.OccurrencePoints;13import io.appium.java_client.imagecomparison.OccurrencePointsWithScore;14import io.appium.java_client.imagecomparison.OccurrencePosition;15import io.appium.java_client.imagecomparison.OccurrencePositionWithScore;16import io.appium.java_client.imagecomparison.OccurrencePositions;17import io.appium.java_client.imagecomparison.OccurrencePositionsWithScore;18import io.appium.java_client.imagecomparison.OccurrenceScore;19import io.appium.java_client.imagecomparison.OccurrenceSettings;20import io.appium.java_client.imagecomparison.OccurrenceTemplate;21import io.appium.java_client.imagecomparison.OccurrenceTemplateSettings;22import io.appium.java_client.imagecomparison.OccurrenceThreshold;23import io.appium.java_client.imagecomparison.OccurrenceThresholdSettings;24import io.appium.java_client.imagecomparison.OccurrenceType;25import io.appium.java_client

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in OccurrenceMatchingOptions

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful