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.

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 static

public 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");

最新文章

  1. SQL SERVER与SSIS 数据类型对应关系
  2. Android PullToRefreshListView上拉刷新和下拉刷新
  3. CEdit的简单用法
  4. To fix sql server 2008 r2 Evaluation period has expired by change the key
  5. 数学之路(3)-机器学习(3)-机器学习算法-SVM[9]
  6. Codeforces Round #256 (Div. 2) 题解
  7. ADO.NET生成的数据库连接字符串解析
  8. [poj2185]Milking Grid_KMP
  9. Vue打包优化之分析工具webpack-bundle-analyzer
  10. redis知识点汇总
  11. 2018-01-02 JavaScript实现ZLOGO: 用语法树实现多层循环
  12. spring cloud feign覆写默认配置级feign client的日志打印
  13. java基础面试(上)
  14. Vue学习资料
  15. Spring boot 入门篇
  16. 写一个针对IQueryable<T>的扩展方法支持动态排序
  17. linux 内核启动流程分析,移植
  18. Robot FrameWork使用中常见问题收集
  19. 深入浅析Spring的AOP实现原理
  20. (转)SQL知识_Sql日期时间格式转换

热门文章

  1. c#笔记2018-12-26
  2. Decorator(装饰器模式)
  3. 2017 Multi-University Training Contest - Team 2
  4. HLG 2025
  5. 九度oj 题目1051:数字阶梯求和
  6. ES6 Arrow Function & this bug
  7. 【Luogu】P1199三国游戏(博弈论)
  8. 干货 | Elasticsearch Nested类型深入详解
  9. Codeforces633G - Yash And Trees
  10. Selenium+Chrome+PhantomJS 爬取淘宝