您好,登錄后才能下訂單哦!
appium操作chrome瀏覽器
1.安卓手機下載手機版chrome瀏覽器
2.Andriod setting中選擇“chrome”
3.通過css定位得到百度輸入框為:#index-kw
4.編寫代碼
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.TouchAction;
import org.junit.*;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;
public class chrome {
private AppiumDriver driver;
private static WebElement element = null;
int port=22;
String url="";@Before
br/>@Before
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","xx");xx->手機設備號
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("appPackage", "com.android.browser");
capabilities.setCapability("appActivity", ".BrowserActivity");
capabilities.setCapability("unicodeKeyboard",true);
capabilities.setCapability("resetKeyboard",true);
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {driver.quit();
}
@Test
br/>driver.quit();
}
@Test
driver.get("http://m.baidu.com");
driver.findElementByCssSelector("#index-kw").sendKeys("suzhou");
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。