APP自动化(java和python)——java操作百度浏览器
Posted 小白龙白龙马
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了APP自动化(java和python)——java操作百度浏览器相关的知识,希望对你有一定的参考价值。
package jkcs; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.remote.DesiredCapabilities; import io.appium.java_client.AppiumDriver; public class jblx { 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("appPackage", "com.baidu.searchbox"); capabilities.setCapability("appActivity", "com.baidu.searchbox.MainActivity"); AppiumDriver driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(300, TimeUnit.SECONDS); Thread.sleep(9000); driver.get("https://m.baidu.com"); System.out.println(driver.currentActivity()); Thread.sleep(5000); driver.get("https://i.ifeng.com/"); System.out.println(driver.getCapabilities()); Thread.sleep(9000); driver.quit(); } }
执行结果:
.MainActivity
Capabilities [{appPackage=com.baidu.searchbox, statBarHeight=84, viewportRect={top=84, left=0, width=1440, height=2344}, deviceName=8DF6R17503000072, platform=LINUX, deviceUDID=8DF6R17503000072, desired={appPackage=com.baidu.searchbox, appActivity=com.baidu.searchbox.MainActivity, platformVersion=8.0.0, unicodeKeyboard=true, platformName=Android, deviceName=8DF6R17503000072, resetKeyboard=true}, platformVersion=8.0.0, webStorageEnabled=false, takesScreenshot=true, javascriptEnabled=true, unicodeKeyboard=true, platformName=Android, deviceApiLevel=26, deviceManufacturer=HUAWEI, resetKeyboard=true, deviceScreenSize=1440x2560, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, appActivity=com.baidu.searchbox.MainActivity, pixelRatio=3.5, locationContextEnabled=false, deviceScreenDensity=560, deviceModel=EDI-AL10}]
以上是关于APP自动化(java和python)——java操作百度浏览器的主要内容,如果未能解决你的问题,请参考以下文章
APP自动化(java和python)——appium学习资源汇总