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

Clipboard management. #144

Merged
merged 5 commits into from
Mar 13, 2021
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 @@ -18,8 +18,15 @@
import static com.github.wasiqb.coteafs.appium.constants.ErrorMessage.SERVER_STOPPED;
import static com.github.wasiqb.coteafs.appium.utils.ErrorUtils.fail;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.imageio.ImageIO;

import com.github.wasiqb.coteafs.appium.android.system.AlertActivity;
import com.github.wasiqb.coteafs.appium.android.system.PermissionActivity;
Expand All @@ -32,6 +39,7 @@
import io.appium.java_client.android.AndroidTouchAction;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import io.appium.java_client.clipboard.ClipboardContentType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.NoSuchSessionException;
Expand All @@ -46,7 +54,7 @@ public class AndroidDeviceActions
private static final Logger LOG = LogManager.getLogger (AndroidDeviceActions.class);

/**
* @param device
* @param device Device under test
*
* @author wasiq.bhamla
* @since 26-Apr-2017 9:05:43 PM
Expand All @@ -64,10 +72,11 @@ public AndroidDeviceActions (final AndroidDevice device) {
public String clipboard () {
LOG.info ("Getting clipboard text...");
return this.driver.getClipboardText ();

}

/**
* @param type
* @param type Type for which to get clipboard value
*
* @return clipboard
*
Expand All @@ -77,6 +86,49 @@ public String clipboard () {
public String clipboard (final ClipboardType type) {
LOG.info ("Getting clipboard for [{}]...", type);
return this.driver.getClipboard (type.getType ());

}

/**
* @param text Set clipboard with text
*
* @author Faisal Khatri
* @since Mar 13, 2021
*/
public void clipboard (final String text) {
LOG.info ("Setting clipboard text to [{}]...", text);
this.driver.setClipboardText (text);
}

/**
* @param url URL to set clipboard with.
*
* @author Wasiq Bhamla
* @since 13-Mar-2021
*/
public void clipboard (final URL url) {
LOG.info ("Setting clipboard URL to [{}]...", url);
this.driver.setClipboard (ClipboardContentType.URL, Base64.getMimeEncoder ()
.encode (url.getPath ()
.getBytes (StandardCharsets.UTF_8)));
}

/**
* @param image Set clipboard with image
*
* @author Wasiq Bhamla
* @since 13-Mar-2021
*/
public void clipboard (final BufferedImage image) {
LOG.info ("Setting clipboard image...");
try (final ByteArrayOutputStream os = new ByteArrayOutputStream ()) {
ImageIO.write (image, "png", os);
this.driver.setClipboard (ClipboardContentType.IMAGE, Base64.getMimeEncoder ()
.encode (os.toByteArray ()));
} catch (final IOException e) {
LOG.error ("Error occurred while setting Image clipboard.");
LOG.catching (e);
}
}

/**
Expand Down Expand Up @@ -114,7 +166,7 @@ public String handleAlert () {
}

/**
* @param buttonText
* @param buttonText Button text to click on
*
* @return message
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class DelaySetting {
private long afterSwipe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public class DeviceSetting {
private DeviceType type = DeviceType.SIMULATOR;
private String version;

/**
* @return Cloud Capabilities
*
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
public boolean isCloud () {
return getCloudCapabilities ().size () > 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class OtherSetting {
private boolean clearFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class ScreenshotSetting {
private boolean onError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import com.github.wasiqb.coteafs.appium.config.enums.VideoQuality;
import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class VideoStreamSetting {
private int bitRate = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class AdbSetting {
private int host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
import com.github.wasiqb.coteafs.appium.config.enums.ApplicationType;
import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class AndroidAppSetting {
private String activityName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class AndroidVideoSetting {
private int bitRate = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class AndroidWebSetting {
private boolean acceptSslCerts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import io.appium.java_client.android.NetworkSpeed;
import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class AvdSetting {
private String args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class WebOptions {
private List<String> args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class WebPerformancePreferences {
private boolean network;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import com.github.wasiqb.coteafs.appium.config.enums.ApplicationType;
import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class IOSAppSetting {
private String bundleId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
import io.appium.java_client.ios.IOSStartScreenRecordingOptions.VideoQuality;
import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class IOSVideoSetting {
private String codec = "mpeg4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class IOSWebSetting {
private boolean allowPopups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class WDASetting {
private String agentPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* @since 29-11-2020
*/
public enum CloudProviders {
/**
* Cloud Provider URL
*
* @since Mar 13, 2021
*/
BROWSERSTACK ("hub-cloud.browserstack.com");

private final String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
package com.github.wasiqb.coteafs.appium.config.enums;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
public enum UnlockType {
FINGERPRINT,
PASSWORD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
package com.github.wasiqb.coteafs.appium.config.enums;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
public enum VideoQuality {
HD (100),
HIGH (75),
Expand All @@ -29,6 +33,9 @@ public enum VideoQuality {
this.quality = quality;
}

/**
* @return video quality
*/
public int getQuality () {
return this.quality;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class AndroidSetting {
private int bootstrapPort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class IOSSetting {
private int backendRetries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
import com.github.wasiqb.coteafs.appium.config.enums.LogLevel;
import lombok.Data;

/**
* @author Wasiq Bhamla
* @since Mar 13, 2021
*/
@Data
public class LogSetting {
private static final String PATH_PATTERN = "{0}/logs/server-{1}.log";
Expand Down
Loading