Skip to content

Commit 34dd16f

Browse files
Merge pull request #596 from SrinivasanTarget/srini-master
Resetting master to Beta5
2 parents 1e2c86e + 48f3a96 commit 34dd16f

File tree

9 files changed

+124
-23
lines changed

9 files changed

+124
-23
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ This is the Java language binding for writing Appium Tests, conforms to [Mobile
2020
##Changelog##
2121
*5.0.0 (under construction yet)*
2222

23+
*5.0.0-BETA5*
24+
- **[UPDATE]** Update to Selenium 3.2.0
25+
- **[BUG FIX]** Excessive dependency on `guava` was removed. It causes errors. Issue report: [#588](https://github.com/appium/java-client/issues/588). FIX: [#589](https://github.com/appium/java-client/pull/589).
26+
- **[ENHANCEMENT]**. The capability `io.appium.java_client.remote.AndroidMobileCapabilityType#SYSTEM_PORT` was added. [#591](https://github.com/appium/java-client/pull/591)
27+
2328
*5.0.0-BETA4*
2429
- **[ENHANCEMENT]** Android. API to read the performance data was added. [#562](https://github.com/appium/java-client/pull/562)
2530
- **[REFACTOR]** Android. Simplified the activity starting by reducing the number of parameters through POJO clas. Old methods which start activities were marked `@Deprecated`. [#579](https://github.com/appium/java-client/pull/579) [#585](https://github.com/appium/java-client/pull/585)

build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'signing'
77
apply plugin: 'maven-publish'
88

99
group 'io.appium'
10-
version '5.0.0-BETA4'
10+
version '5.0.0-BETA5'
1111

1212
repositories {
1313
jcenter()
@@ -54,13 +54,12 @@ compileJava {
5454
}
5555

5656
dependencies {
57-
compile('org.seleniumhq.selenium:selenium-java:3.0.1'){
57+
compile('org.seleniumhq.selenium:selenium-java:3.2.0'){
5858
exclude module: 'cglib'
5959
exclude group: 'com.google.code.gson'
6060
}
6161
compile 'com.google.code.gson:gson:2.8.0'
6262
compile 'org.apache.httpcomponents:httpclient:4.5.2'
63-
compile 'com.google.guava:guava:20.0'
6463
compile 'cglib:cglib:3.2.4'
6564
compile 'commons-validator:commons-validator:1.5.1'
6665
compile 'org.apache.commons:commons-lang3:3.5'

src/main/java/io/appium/java_client/events/DefaultAspect.java

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ public void afterScript(JoinPoint joinPoint) throws Throwable {
352352
public void beforeAlertAccept(JoinPoint joinPoint) throws Throwable {
353353
try {
354354
listener.beforeAlertAccept(driver, castTarget(joinPoint));
355+
listener.beforeAlertAccept(driver);
355356
} catch (Throwable t) {
356357
throw getRootCause(t);
357358
}
@@ -361,6 +362,7 @@ public void beforeAlertAccept(JoinPoint joinPoint) throws Throwable {
361362
public void afterAlertAccept(JoinPoint joinPoint) throws Throwable {
362363
try {
363364
listener.afterAlertAccept(driver, castTarget(joinPoint));
365+
listener.afterAlertAccept(driver);
364366
} catch (Throwable t) {
365367
throw getRootCause(t);
366368
}
@@ -370,6 +372,7 @@ public void afterAlertAccept(JoinPoint joinPoint) throws Throwable {
370372
public void beforeAlertDismiss(JoinPoint joinPoint) throws Throwable {
371373
try {
372374
listener.beforeAlertDismiss(driver, castTarget(joinPoint));
375+
listener.beforeAlertDismiss(driver);
373376
} catch (Throwable t) {
374377
throw getRootCause(t);
375378
}
@@ -379,6 +382,7 @@ public void beforeAlertDismiss(JoinPoint joinPoint) throws Throwable {
379382
public void afterAlertDismiss(JoinPoint joinPoint) throws Throwable {
380383
try {
381384
listener.afterAlertDismiss(driver, castTarget(joinPoint));
385+
listener.afterAlertDismiss(driver);
382386
} catch (Throwable t) {
383387
throw getRootCause(t);
384388
}

src/main/java/io/appium/java_client/events/DefaultListener.java

+20
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,38 @@ public void add(Collection<Listener> listeners) {
142142
((AlertEventListener) dispatcher).beforeAlertAccept(driver, alert);
143143
}
144144

145+
@Override
146+
public void beforeAlertAccept(WebDriver driver) {
147+
((WebDriverEventListener) dispatcher).beforeAlertAccept(driver);
148+
}
149+
145150
@Override public void afterAlertAccept(WebDriver driver, Alert alert) {
146151
((AlertEventListener) dispatcher).afterAlertAccept(driver, alert);
147152
}
148153

154+
@Override
155+
public void afterAlertAccept(WebDriver driver) {
156+
((WebDriverEventListener) dispatcher).afterAlertAccept(driver);
157+
}
158+
149159
@Override public void afterAlertDismiss(WebDriver driver, Alert alert) {
150160
((AlertEventListener) dispatcher).afterAlertDismiss(driver, alert);
151161
}
152162

163+
@Override
164+
public void afterAlertDismiss(WebDriver driver) {
165+
((WebDriverEventListener) dispatcher).afterAlertDismiss(driver);
166+
}
167+
153168
@Override public void beforeAlertDismiss(WebDriver driver, Alert alert) {
154169
((AlertEventListener) dispatcher).beforeAlertDismiss(driver, alert);
155170
}
156171

172+
@Override
173+
public void beforeAlertDismiss(WebDriver driver) {
174+
((WebDriverEventListener) dispatcher).beforeAlertDismiss(driver);
175+
}
176+
157177
@Override public void beforeAlertSendKeys(WebDriver driver, Alert alert, String keys) {
158178
((AlertEventListener) dispatcher).beforeAlertSendKeys(driver, alert, keys);
159179
}

src/main/java/io/appium/java_client/remote/AndroidMobileCapabilityType.java

+5
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,9 @@ public interface AndroidMobileCapabilityType extends CapabilityType {
239239
String ANDROID_SCREENSHOT_PATH = "androidScreenshotPath";
240240

241241
String SELENDROID_PORT = "selendroidPort";
242+
243+
/**
244+
* The port number, which being used by UIAutomator2
245+
*/
246+
String SYSTEM_PORT = "systemPort";
242247
}

src/main/java/org/openqa/selenium/WebDriver.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
package org.openqa.selenium;
1919

20-
import org.openqa.selenium.logging.Logs;
2120
import org.openqa.selenium.logging.LoggingPreferences;
21+
import org.openqa.selenium.logging.Logs;
2222

2323
import java.net.URL;
2424
import java.util.List;
@@ -75,7 +75,7 @@ public interface WebDriver extends SearchContext {
7575
* The title of the current page.
7676
*
7777
* @return The title of the current page, with leading and trailing whitespace stripped, or null
78-
* if one is not already set
78+
* if one is not already set
7979
*/
8080
String getTitle();
8181

@@ -98,7 +98,7 @@ public interface WebDriver extends SearchContext {
9898
* This method is affected by the 'implicit wait' times in force at the time of execution.
9999
* The findElement(..) invocation will return a matching row, or try again repeatedly until
100100
* the configured timeout is reached.
101-
* <p>
101+
*
102102
* findElement should not be used to look for non-present elements, use {@link #findElements(By)}
103103
* and assert zero length response instead.
104104
*
@@ -164,7 +164,7 @@ public interface WebDriver extends SearchContext {
164164
* URL.
165165
*
166166
* @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows the selection of what to
167-
* do next
167+
* do next
168168
*/
169169
Navigation navigate();
170170

@@ -242,7 +242,7 @@ interface Options {
242242

243243
/**
244244
* Gets the {@link Logs} interface used to fetch different types of logs.
245-
* <p>
245+
*
246246
* <p>To set the logging preferences {@link LoggingPreferences}.
247247
*
248248
* @return A Logs interface.
@@ -318,7 +318,7 @@ interface TargetLocator {
318318
* precedence over those matched by ID.
319319
*
320320
* @param nameOrId the name of the frame window, the id of the &lt;frame&gt; or &lt;iframe&gt;
321-
* element, or the (zero-based) index
321+
* element, or the (zero-based) index
322322
* @return This driver focused on the given frame
323323
* @throws NoSuchFrameException If the frame cannot be found
324324
*/
@@ -329,7 +329,7 @@ interface TargetLocator {
329329
*
330330
* @param frameElement The frame element to switch to.
331331
* @return This driver focused on the given frame.
332-
* @throws NoSuchFrameException If the given element is neither an IFRAME nor a FRAME element.
332+
* @throws NoSuchFrameException If the given element is neither an IFRAME nor a FRAME element.
333333
* @throws StaleElementReferenceException If the WebElement has gone stale.
334334
* @see WebDriver#findElement(By)
335335
*/
@@ -347,7 +347,7 @@ interface TargetLocator {
347347
* Switch the focus of future commands for this driver to the window with the given name/handle.
348348
*
349349
* @param nameOrHandle The name of the window or the handle as returned by
350-
* {@link WebDriver#getWindowHandle()}
350+
* {@link WebDriver#getWindowHandle()}
351351
* @return This driver focused on the given window
352352
* @throws NoSuchWindowException If the window cannot be found
353353
*/
@@ -367,7 +367,7 @@ interface TargetLocator {
367367
* "document.activeElement" in Javascript.
368368
*
369369
* @return The WebElement with focus, or the body element if no element with focus can be
370-
* detected.
370+
* detected.
371371
*/
372372
WebElement activeElement();
373373

@@ -461,10 +461,11 @@ interface ImeHandler {
461461
* platform-independent method of activating IME (the platform-specific way being using keyboard
462462
* shortcuts).
463463
*
464+
*
464465
* @param engine name of engine to activate.
465-
* @throws ImeNotAvailableException if the host does not support IME.
466+
* @throws ImeNotAvailableException if the host does not support IME.
466467
* @throws ImeActivationFailedException if the engine is not available or if activation failed
467-
* for other reasons.
468+
* for other reasons.
468469
*/
469470
void activateEngine(String engine);
470471
}
@@ -512,4 +513,4 @@ interface Window {
512513
*/
513514
void fullscreen();
514515
}
515-
}
516+
}

src/main/java/org/openqa/selenium/WebElement.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,18 @@ public interface WebElement extends SearchContext, TakesScreenshot {
3434
* should discard all references to this element and any further
3535
* operations performed on this element will throw a
3636
* StaleElementReferenceException.
37-
* <p>
37+
*
3838
* Note that if click() is done by sending a native event (which is
3939
* the default on most browsers/platforms) then the method will
4040
* _not_ wait for the next page to load and the caller should verify
4141
* that themselves.
42-
* <p>
43-
* <p>
42+
*
4443
* There are some preconditions for an element to be clicked. The
4544
* element must be visible and it must have a height and width
4645
* greater then 0.
4746
*
4847
* @throws StaleElementReferenceException If the element no
49-
* longer exists as initially defined
48+
* longer exists as initially defined
5049
*/
5150
void click();
5251

@@ -69,7 +68,7 @@ public interface WebElement extends SearchContext, TakesScreenshot {
6968
/**
7069
* If this element is a text entry element, this will clear the value. Has no effect on other
7170
* elements. Text entry elements are INPUT and TEXTAREA elements.
72-
* <p>
71+
*
7372
* Note that the events fired by this event may not be as you'd expect. In particular, we don't
7473
* fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider
7574
* using something like {@link #sendKeys(CharSequence...)} with the backspace key. To ensure
@@ -169,7 +168,7 @@ public interface WebElement extends SearchContext, TakesScreenshot {
169168
* This method is affected by the 'implicit wait' times in force at the time of execution.
170169
* The findElement(..) invocation will return a matching row, or try again repeatedly until
171170
* the configured timeout is reached.
172-
* <p>
171+
*
173172
* findElement should not be used to look for non-present elements, use {@link #findElements(By)}
174173
* and assert zero length response instead.
175174
*
@@ -213,7 +212,7 @@ public interface WebElement extends SearchContext, TakesScreenshot {
213212
* Color values should be returned as rgba strings, so,
214213
* for example if the "background-color" property is set as "green" in the
215214
* HTML source, the returned value will be "rgba(0, 255, 0, 1)".
216-
* <p>
215+
*
217216
* Note that shorthand CSS properties (e.g. background, font, border, border-top, margin,
218217
* margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned,
219218
* in accordance with the
@@ -225,4 +224,4 @@ public interface WebElement extends SearchContext, TakesScreenshot {
225224
* @return The current, computed value of the property.
226225
*/
227226
String getCssValue(String propertyName);
228-
}
227+
}

src/test/java/io/appium/java_client/events/WebDriverEventListenerCompatibilityTest.java

+48
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.appium.java_client.events;
22

33
import static org.hamcrest.core.Is.is;
4+
import static org.hamcrest.core.IsCollectionContaining.hasItems;
45
import static org.junit.Assert.assertThat;
56

67
import io.appium.java_client.events.listeners.AppiumListener;
@@ -9,6 +10,8 @@
910
import org.junit.FixMethodOrder;
1011
import org.junit.Test;
1112
import org.junit.runners.MethodSorters;
13+
import org.openqa.selenium.Alert;
14+
import org.openqa.selenium.security.Credentials;
1215

1316
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
1417
public class WebDriverEventListenerCompatibilityTest extends BaseListenerTest {
@@ -56,6 +59,51 @@ public void javaScriptEventTest() {
5659
is(true));
5760
}
5861

62+
@Test
63+
public void alertEventTest() {
64+
try {
65+
Alert alert = driver.switchTo().alert();
66+
alert.accept();
67+
alert.dismiss();
68+
alert.sendKeys("Keys");
69+
Credentials credentials = new Credentials() {
70+
@Override
71+
public int hashCode() {
72+
return super.hashCode();
73+
}
74+
75+
@Override
76+
public String toString() {
77+
return "Test credentials 1";
78+
}
79+
};
80+
81+
Credentials credentials2 = new Credentials() {
82+
@Override
83+
public int hashCode() {
84+
return super.hashCode();
85+
}
86+
87+
@Override
88+
public String toString() {
89+
return "Test credentials 2";
90+
}
91+
};
92+
93+
alert.setCredentials(credentials);
94+
alert.authenticateUsing(credentials2);
95+
96+
assertThat(listener.messages,
97+
hasItems(WEBDRIVER_EVENT_LISTENER + "Attempt to accept alert",
98+
WEBDRIVER_EVENT_LISTENER + "The alert was accepted",
99+
WEBDRIVER_EVENT_LISTENER + "Attempt to dismiss alert",
100+
WEBDRIVER_EVENT_LISTENER + "The alert was dismissed"));
101+
assertThat(listener.messages.size(), is(4));
102+
} finally {
103+
listener.messages.clear();
104+
}
105+
}
106+
59107
@Test
60108
public void exceptionEventTest() {
61109
assertThat(super.assertThatExceptionListenerWorks(driver, listener, WEBDRIVER_EVENT_LISTENER),

src/test/java/io/appium/java_client/events/listeners/AppiumListener.java

+20
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@ public class AppiumListener extends TestListener implements AppiumWebDriverEvent
1010
SingleListeners.listeners.put(AppiumListener.class, this);
1111
}
1212

13+
@Override
14+
public void beforeAlertAccept(WebDriver driver) {
15+
messages.add("WebDriverEventListener: Attempt to accept alert");
16+
}
17+
18+
@Override
19+
public void afterAlertAccept(WebDriver driver) {
20+
messages.add("WebDriverEventListener: The alert was accepted");
21+
}
22+
23+
@Override
24+
public void afterAlertDismiss(WebDriver driver) {
25+
messages.add("WebDriverEventListener: Attempt to dismiss alert");
26+
}
27+
28+
@Override
29+
public void beforeAlertDismiss(WebDriver driver) {
30+
messages.add("WebDriverEventListener: The alert was dismissed");
31+
}
32+
1333
@Override public void beforeNavigateTo(String url, WebDriver driver) {
1434
messages.add("WebDriverEventListener: Attempt to navigate to " + url);
1535
}

0 commit comments

Comments
 (0)