scrollTo(String text) and scrollToExact(String text) method of Android Driver not working
2015-11-02 17:12
666 查看
Using the scrollTo(String text) and scrollToExact(String text) method of Android Driver. However the scrolling is done for the entire contact list first downwards and then upwards but it does not scroll upto the string text provided and in the end throws error- org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
pls help
and
Because you did declare the access modifier for the variable string1. It is private by default. You have to make it public like this:
But that is a bad practice. You would want to have getter and setters for these kinds of jobs. So basically this:
And you access it by calling the method
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(); } }
pls help
2 similar answers
one way is to make the String string1 staticpublic class Favourites extends ActionBarActivity { public static String string1; String st2; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fav); final Button but1 = (Button) findViewById(R.id.button1);
and
Favourites.string1 = Athenry;
Because you did declare the access modifier for the variable string1. It is private by default. You have to make it public like this:
public String string1;
But that is a bad practice. You would want to have getter and setters for these kinds of jobs. So basically this:
private String string1; public String setString1(String s){ string1 = s; }
And you access it by calling the method
Object.setString("Your String");
相关文章推荐
- 调试中手机抓包工具的使用
- 推荐4个Android引导页控件
- Android各个版本版本号对应关系表及悬浮框
- Android大图片裁剪终极解决方案 原理分析
- Android动画之属性动画
- 实现QQ登录第三方APP(Android)
- Android 关于轻量级存储PreferencesUtils
- Android事件总线纷发库EventBus的使用方法
- Android Studio进行单元测试
- Android 对Canvas的translate方法总结
- 定制Android系统开发之八——实现从JNI到Java的回调
- Android学习路线
- Android程序开发:简单电话拨号器
- Android移动view动画问题
- Android的分类ListView
- android学习之Service
- Android程序开发:简单电话拨号器
- Android 中文API —— Spinner
- 获取android系统服务
- Android 源码分析01_AsyncTask