• APP——自动化——java——设置和查看横屏和竖屏


    package csgc;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.ScreenOrientation;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import io.appium.java_client.AppiumDriver;
    
    public class ces 
    {
    
        public static void main(String[] args) throws MalformedURLException, InterruptedException 
        {
    
            DesiredCapabilities capabilities = new DesiredCapabilities();  
    
            capabilities.setCapability("platformName", "Android");  
            capabilities.setCapability("deviceName","8DF6R17503000072");  
            capabilities.setCapability("platformVersion", "8.0.0"); 
            
            capabilities.setCapability("unicodeKeyboard","True");
            capabilities.setCapability("resetKeyboard","True");
            
            capabilities.setCapability("autoGrantPermissions", "True");  
            
         //   capabilities.setCapability("app", "C:\Users\del\Desktop\b\jsq.apk");  
            
            capabilities.setCapability("appPackage", "com.youba.calculate");  
            capabilities.setCapability("appActivity", "com.youba.calculate.MainActivity");  
            
            
            
            
            AppiumDriver driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
            
            
            driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);
            
            
            Thread.sleep(5000);
            
            driver.closeApp();   //只针对当前测试的app,关闭app
    
            
            Thread.sleep(5000);
            
            System.out.println(driver.getOrientation().name());//PORTRAIT竖屏,LANDSCAPE横屏           手机显示: PORTRAIT
            
            Thread.sleep(5000);
            
            driver.rotate(ScreenOrientation.LANDSCAPE);//设置为横屏
    
            
            Thread.sleep(5000);
            
            driver.rotate(ScreenOrientation.PORTRAIT);//设置为竖屏
    
            
            Thread.sleep(5000);
            
            driver.quit();
            
            
    
        }
    
    }
  • 相关阅读:
    MySQL数据库高并发优化配置
    MySQL性能参数详解
    jQuery中过滤选择器first和first-child的区别
    Linux非常用命令
    jps命令学习
    通过乐观锁(版本号)降低并发时的锁竞争
    ReentrantLock 相关学习笔记
    grep 所有多个关键字
    ThreadLocal学习笔记
    Idea设置全白色 背景
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/13198785.html
Copyright © 2020-2023  润新知