Android驱动程序的scrollTo(String text)和scrollToExact(String text)方法无法正常工作

时间:2015-05-05 13:32:38

标签: java android selenium appium

使用Android Driver的scrollTo(String text)和scrollToExact(String text)方法。然而,首先向下然后向上滚动整个联系人列表,但它不向上滚动到提供的字符串文本,最后抛出错误 - org.openqa.selenium.NoSuchElementException:使用给定的搜索参数无法在页面上找到元素。

public class test2 {

//public WebDriver driver;
public AppiumDriver driver1;

 @BeforeClass
 public void setUp() throws MalformedURLException{

//Set up desired capabilities and pass the Android app-activity and app-package to Appium

 DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("platformVersion", "5.0
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability("deviceName", "4763f751");
    capabilities.setCapability("device", "Android");
    capabilities.setCapability("appPackage", "com.android.contacts");             
    capabilities.setCapability("appActivity", "com.android.contacts.activities.PeopleActivity");

  //Create RemoteWebDriver instance and connect to the Appium server.
    driver1 = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"), capabilities);    

 }

 @Test
public void testCal()  throws Exception {

    WebElement clk=driver1.findElement(By.name("some contact name here"));      
    String txt= clk.getText();
     driver1.scrollTo(txt);

 }
@AfterClass
public void teardown(){
//close the app
driver1.quit();
}

}

请帮助

0 个答案:

没有答案