Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit 10410f8

Browse files
committed
better
1 parent 5c39be4 commit 10410f8

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

src/main/java/com/daxiang/action/MobileAction.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,18 @@ public WebElement swipeInContainerToFindElement(WebElement container, String fin
172172

173173
/**
174174
* 1007.弹窗 允许/接受/...
175+
* // todo 转移到BaseAction
175176
*/
176177
public boolean acceptAlert() {
177-
return mobileDevice.acceptAlert();
178+
return device.acceptAlert();
178179
}
179180

180181
/**
181182
* 1008.异步accept alert
182183
*
183184
* @param timeoutInSeconds 超时处理时间
184185
* @param once 是否只处理一次
186+
* // todo 转移到BaseAction
185187
*/
186188
public void asyncAcceptAlert(String timeoutInSeconds, String once) {
187189
long _timeoutInSeconds = parseLong(timeoutInSeconds);
@@ -206,16 +208,18 @@ public void asyncAcceptAlert(String timeoutInSeconds, String once) {
206208

207209
/**
208210
* 1009.弹窗 拒绝/取消/...
211+
* // todo 转移到BaseAction
209212
*/
210213
public boolean dismissAlert() {
211-
return mobileDevice.dismissAlert();
214+
return device.dismissAlert();
212215
}
213216

214217
/**
215218
* 1010.异步dismiss alert
216219
*
217220
* @param timeoutInSeconds 超时处理时间
218221
* @param once 是否只处理一次
222+
* // todo 转移到BaseAction
219223
*/
220224
public void asyncDismissAlert(String timeoutInSeconds, String once) {
221225
long _timeoutInSeconds = parseLong(timeoutInSeconds);

src/main/java/com/daxiang/core/Device.java

+18
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,22 @@ public UploadFile screenshotThenUploadToServer() {
146146
FileUtils.deleteQuietly(screenshotFile);
147147
}
148148
}
149+
150+
public boolean acceptAlert() {
151+
try {
152+
driver.switchTo().alert().accept();
153+
return true;
154+
} catch (Exception e) {
155+
return false;
156+
}
157+
}
158+
159+
public boolean dismissAlert() {
160+
try {
161+
driver.switchTo().alert().dismiss();
162+
return true;
163+
} catch (Exception e) {
164+
return false;
165+
}
166+
}
149167
}

src/main/java/com/daxiang/core/mobile/MobileDevice.java

-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ public MobileDevice(Mobile mobile, AppiumServer appiumServer) {
4141

4242
public abstract void uninstallApp(String app) throws Exception;
4343

44-
public abstract boolean acceptAlert();
45-
46-
public abstract boolean dismissAlert();
47-
4844
public void installApp(File appFile) {
4945
((AppiumDriver) driver).installApp(appFile.getAbsolutePath());
5046
}

src/main/java/com/daxiang/core/mobile/ios/IosDevice.java

-20
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,6 @@ public void uninstallApp(String app) {
105105
IosUtil.uninstallApp(driver, app);
106106
}
107107

108-
@Override
109-
public boolean acceptAlert() {
110-
try {
111-
driver.switchTo().alert().accept();
112-
return true;
113-
} catch (Exception e) {
114-
return false;
115-
}
116-
}
117-
118-
@Override
119-
public boolean dismissAlert() {
120-
try {
121-
driver.switchTo().alert().dismiss();
122-
return true;
123-
} catch (Exception e) {
124-
return false;
125-
}
126-
}
127-
128108
@Override
129109
public void startRecordingScreen() {
130110
IOSStartScreenRecordingOptions iosOptions = new IOSStartScreenRecordingOptions();

0 commit comments

Comments
 (0)