当前位置:网站首页>Using pictures to locate app elements sikulix
Using pictures to locate app elements sikulix
2022-06-22 14:38:00 【qq_ four hundred and ninety-two million four hundred and forty-】
brief introduction :Sikuli It's a novel graphic scripting language , Or an alternative automated testing technology . It is similar to our commonly used automated testing technology ( Tools ) There's a big difference .
sikulix jar Package download address
SikuliX project files : SikuliX
You can also search this in the Alibaba cloud warehouse jar package

You need to download the following 3 A package ,
sikulixapi-2.0.5.jar sikulixapi-2.0.5-win.jar be used for windows
sikulixapi-2.0.5.jar sikulixapi-2.0.5-mac.jar be used for mac The computer

It can also be in pom Add... To the file , However, this method is not recommended , This package will have many dependent packages , The download may fail
You can also refer to :java+win7+eclipse+Maven+sikuli Configuration summary --- Graphic scripting language - Let's have a look
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.0</version>
</dependency>
package com.welab.automation.projects.demo;
import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import lombok.SneakyThrows;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.sikuli.script.Screen;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.Base64;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import static io.appium.java_client.service.local.flags.GeneralServerFlag.LOG_LEVEL;
import static io.appium.java_client.service.local.flags.GeneralServerFlag.SESSION_OVERRIDE;
public class TestSikulix {
public static void main(String[] args) throws URISyntaxException, IOException {
TestSikulix testOpenCV = new TestSikulix();
testOpenCV.startMain();
}
AndroidDriver driver;
@SneakyThrows
public void startMain() throws URISyntaxException, IOException {
DesiredCapabilities devices = new DesiredCapabilities();
devices.setCapability("platformName", "Android");
devices.setCapability("deviceName","emulator-5554");
devices.setCapability("platformVersion", "10");
devices.setCapability("appPackage","com.android.settings");
devices.setCapability("appActivity","com.android.settings.Settings");
devices.setCapability("automation","uiautomator2");
devices.setCapability("unicodeKeyboard", true);
devices.setCapability("resetKeyboard",true);
// Need to open appium server, And start the simulator
//driver= new AndroidDriver(new URL("http://localhost:4723/wd/hub"),devices);
// Don't need to open appium The desktop version
AppiumDriverLocalService service =startAppiumService();
driver = new AndroidDriver(service.getUrl(), devices);
Screen s = new Screen();
// Set element not found , Automatic wait time 10 second
s.setAutoWaitTimeout(10);
String project_path=System.getProperty("user.dir");
System.out.println(System.getProperty("user.dir"));
String path = project_path+ "\\src\\main\\java\\com\\welab\\automation\\projects\\demo\\Notifications.png";
s.click("D:\\images\\test\\test01.png");
Thread.sleep(5000);
s.click("D:\\images\\test\\test02.png");
System.out.println("pass");
}
public void clickMobileElementByPicture(String picPath) throws URISyntaxException, IOException {
File file = new File(picPath);
String base64String = Base64.getEncoder().encodeToString(Files.readAllBytes(file.toPath()));
By by= MobileBy.image(base64String);
findMobileElement(by).click();
}
public MobileElement findMobileElement(By by) {
return (MobileElement) driver.findElement(by);
}
private static AppiumDriverLocalService startAppiumService() {
AtomicInteger port = new AtomicInteger();
AppiumDriverLocalService service = null;
service = new AppiumServiceBuilder()
.usingAnyFreePort()
.withIPAddress("0.0.0.0")
.withArgument(SESSION_OVERRIDE)
.withArgument(LOG_LEVEL, "error")
.usingDriverExecutable(new File("D:\\Program Files\\nodejs\\node.exe"))
.withAppiumJS(new File("C:\\Users\\jeff.xie\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js"))
.build();
Optional.ofNullable(service).ifPresent(s -> {
s.start();
port.set(s.getUrl().getPort());
});
AppiumDriverLocalService appiumDriverLocalService = service;
return service;
}
}
appium combination sikuli The simple practice of _Xiamen_wiley The blog of -CSDN Blog
边栏推荐
- Do you know the scope and process of software project acceptance testing?
- C # paging calculation total pages, current page data set
- Specific methods and steps of PROFINET communication between s7-200smart and Fanuc robot
- 作为程序员,职业规划需要注意的四个阶段
- How to compare the size of two dates in unity and C #
- Perceptron of machine learning
- 基于SSH框架甜品商城管理系统【源码+数据库】
- Z-Score和deltf/f有什么区别?
- Policy deployment of firewall Foundation
- 如何理解fold change?倍数分析?
猜你喜欢

Instanceinforeplicator class of Eureka (service registration auxiliary class)

看完這篇 教你玩轉滲透測試靶機Vulnhub——DriftingBlues-5

位置编码(PE)是如何在Transformers中发挥作用的

Offline physical stores combined with VR panorama make virtual shopping more realistic

Open source SPL redefines OLAP server

Shan Zhiguang, chairman of BSN Development Alliance: DDC can provide the underlying support for the development of China's meta universe industry

网络地址转换NAT

Verification code is the natural enemy of automation? See how the great God solved it

Aliyundrive fuse that allows jellyfin to directly mount alicloud disks

How to add a mask to a VR panoramic work? What is the function?
随机推荐
Support vector machine for machine learning
How many days are there between the two timestamps of PHP
d的破坏与安全
Cosmos、Polkadot
JasperReport报表生成工具的基本使用和常见问题
Screenshot of the uniapp app and save it locally
After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-5
How to implement interface exception scenario testing? Exploration of test methods and implementation of test tools
Analysis on data skew of redis slice cluster
基于SSM框架实现的甜品饮品店前后台管理系统甜品商城蛋糕店【源码+数据库】
Unity sub thread calls UI of main thread
How to protect WordPress websites from cyber attacks? It is important to take safety measures
Z-Score和deltf/f有什么区别?
Chip silicon and streaming technology
什么是Bout?
3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World
机器学习之感知机
如何理解fold change?倍数分析?
MadCap Flare 2022,语言或格式的文档
【无标题】