Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition to #846 and #855: #869

Merged
merged 2 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ default String getClipboard(ClipboardContentType contentType) {
*/
default void setClipboardText(String text) {
setClipboard(ClipboardContentType.PLAINTEXT, Base64
.getEncoder()
.getMimeEncoder()
.encode(text.getBytes(StandardCharsets.UTF_8)));
}

Expand All @@ -72,7 +72,7 @@ default void setClipboardText(String text) {
*/
default String getClipboardText() {
byte[] base64decodedBytes = Base64
.getDecoder()
.getMimeDecoder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did suggested this in last PR. How did i missed it. Good catch @TikhomirovSergey

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mykola-mokhnach Last time when i locally built Appium's WDA(Forked) and tested clipboard of URL's where passing in iOS after your fix here but now i upgraded my XCUI driver to latest release but URL's stopped working after that.

URL's are working only if i use mime decoding for URL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make mime decoding for getClipboardUrl too? Else it is failing...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SrinivasanTarget Will make that today

.decode(getClipboard(ClipboardContentType.PLAINTEXT));
return new String(base64decodedBytes, StandardCharsets.UTF_8);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ default void setClipboardImage(BufferedImage img) throws IOException {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
ImageIO.write(checkNotNull(img), "png", os);
setClipboard(ClipboardContentType.IMAGE, Base64
.getEncoder()
.getMimeEncoder()
.encode(os.toByteArray()));
}
}
Expand All @@ -55,7 +55,7 @@ default void setClipboardImage(BufferedImage img) throws IOException {
*/
default BufferedImage getClipboardImage() throws IOException {
final byte[] base64decodedBytes = Base64
.getDecoder()
.getMimeDecoder()
.decode(getClipboard(ClipboardContentType.IMAGE));
return ImageIO.read(new ByteArrayInputStream(base64decodedBytes));
}
Expand All @@ -67,7 +67,7 @@ default BufferedImage getClipboardImage() throws IOException {
*/
default void setClipboardUrl(URL url) {
setClipboard(ClipboardContentType.URL, Base64
.getEncoder()
.getMimeEncoder()
.encode(checkNotNull(url).toString().getBytes(StandardCharsets.UTF_8)));
}

Expand All @@ -79,7 +79,7 @@ default void setClipboardUrl(URL url) {
*/
default URL getClipboardUrl() throws MalformedURLException {
final byte[] base64decodedBytes = Base64
.getDecoder()
.getMimeDecoder()
.decode(getClipboard(ClipboardContentType.URL));
return new URL(new String(base64decodedBytes, StandardCharsets.UTF_8));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.W3CHttpCommandCodec;
import org.openqa.selenium.remote.internal.ApacheHttpClient;
import org.openqa.selenium.remote.internal.OkHttpClient;
import org.openqa.selenium.remote.service.DriverService;

import java.io.IOException;
Expand Down Expand Up @@ -70,12 +70,12 @@ public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,

public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
URL addressOfRemoteServer) {
this(additionalCommands, addressOfRemoteServer, new ApacheHttpClient.Factory());
this(additionalCommands, addressOfRemoteServer, new OkHttpClient.Factory());
}

public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
DriverService service) {
this(additionalCommands, service, new ApacheHttpClient.Factory());
this(additionalCommands, service, new OkHttpClient.Factory());
}

private <B> B getPrivateFieldValue(String fieldName, Class<B> fieldType) {
Expand Down