-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathTabViewPage.java
59 lines (49 loc) · 2.04 KB
/
TabViewPage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package Pages;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
public class TabViewPage extends BasePage{
private static final double START_OFFSET = 0.95;
private static final double END_OFFSET = 0.05;
private static final int SWIPE_DURATION = 1000;
private static final int ALERT_POP_UP_DELAY = 1000;
private static final String BAD_VIDEO_TEXT = "Can't play this video.";
private static final String OK_BUTTON_NAME = "OK";
@AndroidFindBy(id = "container_body")
private MobileElement tabViewContainer;
public TabViewPage(AppiumDriver driver) {
super(driver);
}
public void turnPageLeft() throws InterruptedException {
acceptBadVideoAlert();
Dimension size = driver.manage().window().getSize();
int startX = (int) (size.width * START_OFFSET);
int endX = (int) (size.width * END_OFFSET);
int startY = size.height / 4;
driver.swipe(startX, startY, endX, startY, SWIPE_DURATION);
acceptBadVideoAlert();
}
private void acceptBadVideoAlert() throws InterruptedException {
Thread.sleep(ALERT_POP_UP_DELAY);
if (!driver.findElementsById("android:id/message").isEmpty()) {
WebElement okButton = driver.findElementById("android:id/button1");
okButton.click();
}
}
}