How to use value method of org.openqa.selenium.Enum ScreenOrientation class

Best Selenium code snippet using org.openqa.selenium.Enum ScreenOrientation.value

Source:ZetaAndroidDriver.java Github

copy

Full Screen

...71 public int getCode() {72 return this.code;73 }74 public static SurfaceOrientation getByCode(int code) {75 for (SurfaceOrientation item : SurfaceOrientation.values()) {76 if (code == item.getCode()) {77 return item;78 }79 }80 throw new NoSuchElementException(String.format(81 "There is no SurfaceOrientation item with code '%s'", code));82 }83 }84 public ZetaAndroidDriver(URL remoteAddress, Capabilities desiredCapabilities) {85 super(remoteAddress, desiredCapabilities);86 this.touch = new RemoteTouchScreen(getExecuteMethod());87 try {88 initOSVersionString();89 } catch (Exception e) {...

Full Screen

Full Screen

Source:Device.java Github

copy

Full Screen

...79 }80 /​**81 * Get device type.82 *83 * @return DeviceType enum value.84 */​85 public DeviceType getType() {86 return this.device.getType();87 }88 /​**89 * Start installed application with given package id.90 *91 * @param packageId PackageID of application.92 */​93 public void startApplication(String packageId) {94 this.device.startApplication(packageId);95 }96 /​**97 * Start device.98 * 1. Start device.99 * 2. Start appium session.100 * 3. Ensure app is running.101 *102 * @throws DeviceException When device is not available.103 * @throws TimeoutException When fail to start device in specified time.104 * @throws MobileAppException When app fail to start.105 */​106 public void start() throws DeviceException, TimeoutException, MobileAppException {107 if (this.settings.platform == PlatformType.Android) {108 this.device = new AndroidDevice(this.client, this.settings);109 } else if (this.settings.platform == PlatformType.iOS) {110 this.device = new IOSDevice(this.client, this.settings);111 } else {112 String error = "No such device implemented";113 LOGGER_BASE.fatal(error);114 throw new DeviceException(error);115 }116 this.device = this.device.start();117 /​/​ Verify app is running.118 this.verifyAppRunning(this.settings.packageId);119 this.logAppStartupTime(this.settings.packageId);120 /​/​ Set windowSize121 this.windowSize = this.client.driver.manage().window().getSize();122 }123 /​**124 * Stop device (kills emulator/​simulator).125 */​126 public void stop() throws DeviceException {127 this.device.stop();128 }129 /​**130 * Push file from host machine to mobile device.131 *132 * @param localPath Full path to local file.133 * @param remotePath Remote folder.134 * @throws Exception When operation fails.135 */​136 public void pushFile(String localPath, String remotePath) throws Exception {137 this.device.pushFile(localPath, remotePath);138 }139 /​**140 * Pull file from mobile device to host machine.141 * destinationFolder is relative path based on this.settings.baseLogDir.142 * If destinationFolder is null then file will be saved in this.settings.baseLogDir143 *144 * @param remotePath Full path to remove file.145 * @param destinationFolder Path to host folder.146 * @throws Exception147 */​148 public void pullFile(String remotePath, String destinationFolder) throws Exception {149 this.device.pullFile(remotePath, destinationFolder);150 }151 /​**152 * Clean console logs.153 */​154 public void cleanConsoleLog() {155 this.device.cleanConsoleLog();156 }157 /​**158 * Write console logs in file.159 *160 * @param fileName file name (will be saved in default console log folder).161 * @throws IOException When fails to write in file.162 */​163 public void writeConsoleLogToFile(String fileName) throws IOException {164 this.device.writeConsoleLogToFile(fileName);165 }166 /​**167 * Assert log contains a string.168 *169 * @param str String that should be available in logs.170 * @throws IOException When fail to write current log (it first write it to disk and then get the content).171 */​172 public void assertLogContains(String str) throws IOException {173 String testName = MobileSetupManager.getTestSetupManager().getContext().getTestName();174 String logContent = this.getLogContent(testName);175 Assert.assertTrue(logContent.contains(str), "The log does not contain '" + str + "'.");176 LOGGER_BASE.info("The log contains '" + str + "'.");177 }178 /​**179 * Assert log does not contain a string.180 *181 * @param str String that should not be available in logs.182 * @throws IOException When fail to write current log (it first write it to disk and then get the content).183 */​184 public void assertLogNotContains(String str) throws IOException {185 String testName = MobileSetupManager.getTestSetupManager().getContext().getTestName();186 String logContent = this.getLogContent(testName);187 Assert.assertFalse(logContent.contains(str), "The log contains '" + str + "'.");188 LOGGER_BASE.info("The log does not contains '" + str + "'.");189 }190 /​**191 * Verify app is running.192 *193 * @param appId Package ID of application.194 * @throws MobileAppException195 */​196 public void verifyAppRunning(String appId) throws MobileAppException {197 this.device.verifyAppRunning(appId);198 }199 /​**200 * Check if app is running.201 *202 * @param appId Package ID of application.203 * @return True if app is running and False when it is not.204 */​205 public boolean isAppRunning(String appId) {206 return this.device.isAppRunning(appId);207 }208 /​**209 * Startup time of application in ms.210 *211 * @param packageId PackageId of application.212 * @return Application startup time in ms.213 */​214 public String getStartupTime(String packageId) {215 return this.device.getStartupTime(packageId);216 }217 /​**218 * Memory usage of application in kB.219 *220 * @param packageId PackageId of application.221 * @return Current application memory usage in kB.222 */​223 public int getMemUsage(String packageId) {224 return this.device.getMemUsage(packageId);225 }226 /​**227 * Log perforamcne info such as memory usage, load time, app size in CSV file.228 *229 * @throws IOException When fail to write in csv file.230 */​231 public void logPerfInfo() throws IOException {232 this.device.logPerfInfo();233 }234 /​**235 * Log startup time info in CSV file. IOException is catched if fails to write in csv file or to get startup time.236 */​237 public void logAppStartupTime(String packageId) {238 this.device.logAppStartupTime(packageId);239 }240 /​**241 * Get console logs during execution of current test.242 *243 * @return Console log as string244 * @throws IOException When log fail to be writen in file.245 */​246 private String getLogContent(String testName) throws IOException {247 this.writeConsoleLogToFile(testName);248 return this.device.getContent(testName);249 }250 /​**251 * Restart app under test.252 */​253 public void restartApp() {254 this.device.restartApp();255 }256 /​**257 * Uninstall user application.258 */​259 public void uninstallApps() throws DeviceException {260 this.device.uninstallApps();261 }262 /​**263 * Set geo location.264 *265 * @param location Geo location.266 */​267 public void setLocation(Location location) {268 this.device.setLocation(location);269 }270 /​**271 * Run current application in background.272 *273 * @param seconds Seconds to run in background.274 */​275 public void runAppInBackground(int seconds) {276 LOGGER_BASE.info("Run current app in background for " + seconds + " seconds.");277 this.device.runAppInBackGround(seconds);278 LOGGER_BASE.info("Bring " + this.settings.packageId + " to front.");279 }280 /​**281 * Close current app.282 */​283 public void closeApp() {284 this.device.closeApp();285 }286 /​**287 * List of user apps (apps that are safe to be uninstalled).288 *289 * @return List of package ids.290 */​291 public static List<String> uninstallAppsList() {292 /​/​ TODO(dtopuzov): Do not use hardcoded app names.293 return Arrays.asList("org.nativescript", "com.telerik");294 }295 /​**296 * Get mobile device window size.297 *298 * @return Window size.299 */​300 public Dimension getWindowSize() {301 return this.windowSize;302 }303 /​**304 * Get current screen as BufferedImage.305 *306 * @return BufferedImage of mobile device. Null if getScreenshot fails.307 */​308 public BufferedImage getScreenshot() {309 try {310 File screen = this.client.driver.getScreenshotAs(OutputType.FILE);311 BufferedImage image = ImageIO.read(screen);312 if (this.settings.automationName.equals("UiAutomator1")) {313 return image.getSubimage(0, 0, image.getWidth() - 2, image.getHeight() - 2);314 } else {315 return image;316 }317 } catch (Exception e) {318 LOGGER_BASE.error("Failed to take screenshot! May be appium driver is dead.");319 return null;320 }321 }322 /​**323 * Rotate the device.324 *325 * @param screenOrientation ScreenOrientation enum value.326 */​327 public void rotate(ScreenOrientation screenOrientation) {328 this.client.driver.rotate(screenOrientation);329 }330 public void hideKeyboard() {331 MobileContext mobileContext = MobileSetupManager.getTestSetupManager().getContext();332 if (this.settings.platform == PlatformType.Android) {333 try {334 this.client.getDriver().hideKeyboard();335 LOGGER_BASE.info("Hide heyboard.");336 } catch (Exception e) {337 LOGGER_BASE.info("Soft keyboard not present.");338 }339 } else {...

Full Screen

Full Screen

Source:QtWebKitDriver.java Github

copy

Full Screen

...113 execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation", orientation));114 }115 @Override116 public ScreenOrientation getOrientation() {117 return ScreenOrientation.valueOf(118 (String) execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue());119 }120 @Override121 public AppCacheStatus getStatus() {122 Long status = (Long) execute(DriverCommand.GET_APP_CACHE_STATUS).getValue();123 long st = status;124 return AppCacheStatus.getEnum((int)st);125 }126 @Override127 public MultiTouchScreen getMultiTouch() {128 return multiTouchScreen;129 }130 @Override131 public TouchScreen getTouch() {...

Full Screen

Full Screen

Source:AndroidDriver.java Github

copy

Full Screen

...106 public void rotate(ScreenOrientation orientation) {107 execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation", orientation));108 }109 public ScreenOrientation getOrientation() {110 return ScreenOrientation.valueOf(111 (String) execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue());112 }113 private static URL getDefaultUrl() {114 try {115 return new URL("http:/​/​localhost:8080/​wd/​hub");116 } catch (MalformedURLException e) {117 throw new WebDriverException("Malformed default remote URL: " + e.getMessage());118 }119 }120 public TouchScreen getTouch() {121 return touch;122 }123 public LocalStorage getLocalStorage() {124 return localStorage;...

Full Screen

Full Screen

Source:PropertyWebDriverProvider.java Github

copy

Full Screen

...13 * <li>"firefox": {@link FirefoxDriver}</​li>14 * <li>"ie": {@link InternetExplorerDriver}</​li>15 * <li>"phantomjs": {@link PhantomJSDriver}</​li>16 * </​ul>17 * Property values are case-insensitive and defaults to "firefox" if no18 * "browser" system property is found.19 * <p>20 * The drivers also accept the following properties:21 * <ul>22 * <li>"android": "webdriver.android.url" and23 * "webdriver.android.screenOrientation", defaulting to24 * "http:/​/​localhost:8080/​hub" and "portrait".</​li>25 * <li>"htmlunit": "webdriver.htmlunit.javascriptEnabled", defaulting to "true".26 * </​li>27 * </​ul>28 */​29public class PropertyWebDriverProvider extends DelegatingWebDriverProvider {30 public enum Browser {31 ANDROID, CHROME, FIREFOX, HTMLUNIT, IE, PHANTOMJS32 }33 public void initialize() {34 Browser browser = Browser.valueOf(Browser.class, System.getProperty("browser", "firefox").toUpperCase(usingLocale()));35 delegate.set(createDriver(browser));36 }37 private WebDriver createDriver(Browser browser) {38 switch (browser) {39 case ANDROID:40 return createAndroidDriver();41 default:42 return createChromeDriver();43 case FIREFOX:44 return createFirefoxDriver();45 case HTMLUNIT:46 case IE:47 return createInternetExplorerDriver();48 case PHANTOMJS:...

Full Screen

Full Screen

Source:ScreenOrientation.java Github

copy

Full Screen

...3{4 LANDSCAPE("landscape"), 5 PORTRAIT("portrait");6 7 private final String value;8 9 private ScreenOrientation(String value) {10 this.value = value;11 }12 13 public String value() {14 return value;15 }16}...

Full Screen

Full Screen

value

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.ScreenOrientation;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.remote.DesiredCapabilities;4import org.openqa.selenium.remote.RemoteWebDriver;5import java.net.URL;6import java.net.MalformedURLException;7public class App {8 public static void main(String[] args) throws MalformedURLException {9 DesiredCapabilities capabilities = new DesiredCapabilities();10 capabilities.setCapability("deviceName", "Nexus 5");11 capabilities.setCapability("platformName", "Android");12 capabilities.setCapability("platformVersion", "5.1.1");13 capabilities.setCapability("browserName", "Chrome");

Full Screen

Full Screen

value

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Enum2import org.openqa.selenium.ScreenOrientation3import org.openqa.selenium.WebDriver4import org.openqa.selenium.remote.DesiredCapabilities5import org.openqa.selenium.remote.RemoteWebDriver6import org.openqa.selenium.remote.SessionId7import java.net.URL8import java.util.concurrent.TimeUnit9import org.openqa.selenium.remote.RemoteWebElement10import org.openqa.selenium.WebElement11def caps = DesiredCapabilities.chrome()12try {13 driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS)14 driver.findElement(By.name("q")).sendKeys("TestObject")15 driver.findElement(By.name("btnK")).click()16 println driver.getOrientation()17} finally {18 driver.quit()19}20import org.openqa.selenium.Enum21import org.openqa.selenium.ScreenOrientation22import org.openqa.selenium.WebDriver23import org.openqa.selenium.remote.DesiredCapabilities24import org.openqa.selenium.remote.RemoteWebDriver25import org.openqa.selenium.remote.SessionId26import java.net.URL27import java.util.concurrent.TimeUnit28import org.openqa.selenium.remote.RemoteWebElement29import org.openqa.selenium.WebElement30def caps = DesiredCapabilities.chrome()31try {32 driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS)33 driver.findElement(By.name("q")).sendKeys("TestObject")34 driver.findElement(By.name("btnK")).click()

Full Screen

Full Screen

value

Using AI Code Generation

copy

Full Screen

1var orientation = driver.getOrientation();2var orientation = driver.getOrientation().valueOf(orientation);3var orientation = driver.getOrientation().name(orientation);4var orientation = driver.getOrientation().toString(orientation);5var orientation = driver.getOrientation().equals(orientation);6var orientation = driver.getOrientation().hashCode(orientation);7var orientation = driver.getOrientation().compareTo(orientation);8var orientation = driver.getOrientation().compareTo(orientation);9var orientation = driver.getOrientation().compareTo(orientation);10var orientation = driver.getOrientation().compareTo(orientation);

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Enum-ScreenOrientation

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful