forked from appium/java-client
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExecuteDriverScriptTest.java
More file actions
51 lines (45 loc) · 1.89 KB
/
ExecuteDriverScriptTest.java
File metadata and controls
51 lines (45 loc) · 1.89 KB
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
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 io.appium.java_client.android;
import io.appium.java_client.driverscripts.ScriptOptions;
import io.appium.java_client.driverscripts.ScriptType;
import io.appium.java_client.driverscripts.ScriptValue;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
public class ExecuteDriverScriptTest extends BaseAndroidTest {
@Test
public void verifyBasicScriptExecution() {
String script = String.join("\n", Arrays.asList(
"const status = await driver.status();",
"console.warn('warning message');",
"return status;")
);
ScriptValue value = driver.executeDriverScript(script, new ScriptOptions()
.withTimeout(5000)
.withScriptType(ScriptType.WEBDRIVERIO));
//noinspection unchecked
assertNotNull(((Map<String, Object>) value.getResult()).get("build"));
//noinspection unchecked
assertThat(((List<String>)value.getLogs().get("warn")).get(0),
is(equalTo("warning message")));
}
}