# selenide-appium
Selenide adaptor for Appium framework. It defines concise fluent API, natural language assertions and lets you focus
on the business logic of your tests.
### How to add dependency to your project
Just add to pom.xml:
```xml
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide-appium</artifactId>
<version>7.0.4</version>
</dependency>
```
### Initiating Android / Ios Driver Session
1. Create a class and implement WebDriverProvider interface
```java
@ParametersAreNonnullByDefault
public class AndroidDriverForApiDemos implements WebDriverProvider {
@Override
@CheckReturnValue
@Nonnull
public WebDriver createDriver(Capabilities capabilities) {
UiAutomator2Options options = new UiAutomator2Options();
options.merge(capabilities);
options.setPlatformName("Android");
options.setPlatformVersion("9.0");
options.setDeviceName("Android Emulator");
options.setNewCommandTimeout(Duration.ofSeconds(11));
options.setFullReset(false);
options.setApp("path-to-apk-file");
try {
return new AndroidDriver(new URL("http://127.0.0.1:4723/"), options);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
```
2. Set `Configuration.browser = AndroidDriverForApiDemos.class.getName();` // class name which implemented WebDriverProvider interface in previous step
3. Call `SelenideAppium.launchApp();`
```java
@Test
void testAndroidTap() {
Configuration.browser = AndroidDriverWithCalculator.class.getName();
SelenideAppium.launchApp();
$(AppiumBy.xpath(".//*[@text='Views']")).shouldBe(visible).click(tap());
$(AppiumBy.xpath(".//*[@text='Animation']")).shouldBe(visible);
}
```
### Features
1. Additional [Android Locators](https://github.com/selenide/selenide/blob/main/modules/appium/src/test/java/it/mobile/android/AndroidSelectorsTest.java) and [iOS selectors](https://github.com/selenide/selenide/blob/main/modules/appium/src/test/java/it/mobile/ios/IosSelectorsTest.java)
2. Working with Deep links is easier than ever
```java
SelenideAppium.openAndroidDeepLink("mydemoapprn://product-details/1", "com.saucelabs.mydemoapp.rn");
SelenideAppium.openIOSDeepLink("mydemoapprn://product-details/1");
```
3. Wrapper methods
```java
$(AppiumBy.xpath(".//*[@text='Views']")).click(tap()); //perform native event tap
$(AppiumBy.xpath(".//*[@text='Views']")).tap(); //perform native event tap
$(AppiumBy.xpath(".//*[@text='Views']")).doubleTap(); //perform native event double tap
$(AppiumBy.xpath(".//*[@text='Views']")).click(tapWithOffset(100, -60)) //perform tap with offset from center of the element
$(AppiumBy.xpath(".//*[@text='People Names']")).click(longPress());
$(AppiumBy.xpath(".//*[@text='People Names']")).click(longPressFor(ofSeconds(5)));
$(AppiumBy.xpath(".//*[@text='People Names']")).tap(longPressFor(ofSeconds(4)));
```
4. Drag and drop
```java
SelenideElement source = $(By.id("io.appium.android.apis:id/drag_dot_1")).shouldBe(visible);
SelenideElement target = $(By.id("io.appium.android.apis:id/drag_dot_2")).shouldBe(visible);
source.dragAndDrop(to(target));
```
5. Don't worry about casts
```java
AndroidDriver androidDriver = AppiumDriverRunner.getAndroidDriver();
IOSDriver iosDriver = AppiumDriverRunner.getIosDriver();
boolean isAndroid = AppiumDriverRunner.isAndroidDriver();
boolean isIos = AppiumDriverRunner.isIosDriver();
```
6. Rich Assertions
In Appium, it is common that we want to extract values from different attributes.
_Appium way:_
```java
public String getAttribute() {
return driver instance of AndroidDriver
? mobileELement.getAttribute("content-desc")
: mobileELement.getAttribute("name")
}
// Assertion in test
Assertions.assertThat(getAttribute()).isEqualTo("expected-value")
```
_Selenide-Appium way:_
```java
/*
if android, fetch text attribute and assert with value
if ios, fetch name attribute and assert with value
*/
CombinedAttribute combinedAttribute = CombinedAttribute.android("text").ios("name");
$(element).shouldHave(AppiumCondition.attribute(combinedAttribute, "value"));
```
We can also assert collection
```java
CombinedAttribute combinedAttribute = CombinedAttribute.android("content-desc").ios("label");
List<String> expectedList = Arrays.asList("API Demos", "KeyEventText", "Linkify", "LogTextBox", "Marquee", "Unicode");
$$(AppiumBy.xpath("//android.widget.TextView"))
.shouldHave(AppiumCollectionCondition.attributes(combinedAttribute, expectedList));
```
7. We handle the scrolling for you
```java
$(By.xpath(".//*[@text='Tabs']")).scrollTo().click(); //scroll max of 30 times in downward direction to find element
$(By.xpath(".//*[@text='Tabs']")).scroll(with(DOWN, 10)); //scroll max of 10 times in downward direction to find element
$(By.xpath(".//*[@text='Animation']")).scroll(up()); //scroll max of 30 times in upward direction to find element
$(By.xpath(".//*[@text='Animation']")).scroll(up(0.15f, 0.60f)); //scroll max of 30 times in upward direction with custom swiping height relative to device height
$(By.xpath(".//*[@text='Animation']")).scroll(down(0.15f, 0.60f)); //scroll max of 30 times in downward direction with custom swiping height relative to device height
```
8. We got covered you to the left and right
```java
$(By.xpath(".//*[@text='Tabs']")).swipeTo().click(); //swipe max of 30 times in right direction to find element
$(By.xpath(".//*[@text='Tabs']")).swipe(left()).click(); //swipe max of 30 times in left direction to find element
$(By.xpath(".//*[@text='Tabs']")).swipe(left(10)).click(); //swipe max of 10 times in left direction to find element
```
9. Not able to use page factory for dynamic elements? We got you covered with CombinedBy for writing dynamic locators for both android and ios platforms
```java
int index = 1;
CombinedBy username = CombinedBy
.android(AppiumBy.xpath("(//android.widget.EditText)["+index+"]"))
.ios(AppiumBy.xpath("(//XCUIElementTypeTextField)["+index+"]"));
$(username).setValue("selenide-rocks");
```
### Changelog
* Here is [CHANGELOG](https://github.com/selenide/selenide-appium/blob/main/CHANGELOG) for selenide-appium 1.0.0 ... 2.8.1
* Here is [CHANGELOG](https://github.com/selenide/selenide/blob/main/CHANGELOG.md) for selenide-appium 6.15.0+
### Reference
Please check our [sample project](https://github.com/selenide-examples/selenide-appium).
Please check our [simple skeleton framework](https://github.com/amuthansakthivel/SelenideAppiumFramework)
没有合适的资源?快使用搜索试试~ 我知道了~
Concise UI Tests with Java!.zip
共1193个文件
java:979个
html:71个
js:25个
需积分: 1 0 下载量 74 浏览量
2023-12-29
20:39:43
上传
评论
收藏 3.26MB ZIP 举报
温馨提示
Concise UI Tests with Java!.zip
资源推荐
资源详情
资源评论
收起资源包目录
Concise UI Tests with Java!.zip (1193个子文件)
gradlew.bat 3KB
CHANGELOG 7KB
com.codeborne.selenide.commands.Clear 59B
com.codeborne.selenide.commands.Clear 38B
com.codeborne.selenide.ClipboardService 53B
com.codeborne.selenide.ClipboardService 46B
com.codeborne.selenide.ClipboardService 40B
com.codeborne.selenide.commands.Commands 62B
com.codeborne.selenide.commands.Commands 41B
hello_world.crdownload 26B
jquery-ui.min.css 31KB
tiny.dmg 43B
com.codeborne.selenide.impl.DownloadFileToFolder 49B
com.codeborne.selenide.impl.DownloadFileToFolder 44B
.editorconfig 246B
com.codeborne.selenide.impl.ElementCommunicator 56B
com.codeborne.selenide.impl.ElementCommunicator 51B
com.codeborne.selenide.impl.ElementDescriber 53B
com.codeborne.selenide.impl.ElementDescriber 53B
com.codeborne.selenide.ex.ErrorFormatter 59B
com.codeborne.selenide.ex.ErrorFormatter 49B
tiny.exe 43B
.gitattributes 54B
.gitignore 243B
tests.gradle 5KB
publish-module.gradle 2KB
dependencies.gradle 2KB
code-analysis.gradle 1KB
build.gradle 1KB
build.gradle 1KB
build.gradle 1KB
build.gradle 1KB
javadoc.gradle 918B
build.gradle 757B
build.gradle 684B
build.gradle 659B
build.gradle 606B
build.gradle 602B
build.gradle 584B
build.gradle 462B
compilation.gradle 434B
build.gradle 361B
settings.gradle 346B
coverage.gradle 147B
gradlew 8KB
page_with_selects_without_jquery.html 8KB
page_with_shadow_dom.html 4KB
page_with_multiple_select.html 3KB
page_with_double_clickable_button.html 2KB
page_with_alerts.html 2KB
page_with_uploads.html 2KB
page_with_big_divs.html 2KB
autocomplete.html 2KB
page_with_readonly_elements.html 2KB
page_with_dynamic_select.html 2KB
downloadMultipleFiles.html 1KB
page_with_jquery.html 1KB
page_with_cross-origin-request.html 1KB
page_with_inputs_and_hints.html 1KB
cookies.html 1KB
page_with_relative_click_position.html 1KB
session-storage.html 1KB
file_upload_without_form.html 1KB
long_ajax_request.html 1KB
local-storage.html 1KB
collection_with_changing_texts.html 1KB
clipboard.html 1KB
hover.html 992B
page_with_inputevents_on_clear.html 989B
draggable.html 981B
page_with_transparent_elements.html 963B
page_with_moving_elements.html 926B
page_with_selectable_text.html 846B
page_with_disabled_elements.html 772B
collection_with_delays.html 763B
page_with_svg.html 740B
elements_disappear_on_click.html 727B
html5_input.html 725B
page_with_tabs.html 715B
page_with_date_input.html 703B
page_with_tabs_with_big_delays.html 701B
page_with_tabs_with_delays.html 700B
file_upload_form.html 679B
page_with_input_disappearing_on_clear.html 675B
page_with_datetime_inputs.html 669B
select_events.html 648B
page_with_frames.html 564B
page_with_divs.html 562B
page_with_js_errors.html 551B
page_with_hash.html 541B
page_with_link_to_slow_page.html 513B
page_with_frames_with_big_delays.html 510B
page_with_pseudo_elements.html 481B
page_with_frames_with_delays.html 480B
page_with_selects.html 463B
page_of_fixed_size_2200x3300.html 450B
select_events_multiple.html 445B
page_with_list_of_elements.html 427B
page_with_images.html 421B
page_with_suslik.html 393B
共 1193 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
zero2100
- 粉丝: 161
- 资源: 2464
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功