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

scrollTo(String text) and scrollToExact(String text) method of Android Driver not working的更多相关文章

  1. "text"和new String("text")的区别

    转自:What is the difference between “text” and new String(“text”)? new String("text"); expli ...

  2. Hadoop: Text类和String类的比较

    一般认为Text类和String类是等价的,但二者之间其实存在着不小差别: 以<Hadoop权威指南>中的案例为例,给定字符串  String s = "\u0041\u00DF ...

  3. 解决Android报错No resource found that matches the given name (at 'text' with value '@string/hello').

    解决Android项目No resource found that matches the given name (at 'text' with value '@string/hello'). 如图, ...

  4. 定义私有属性: *String name; * int age; * String gender; * int salary; Date hiredate;//入职时间

    import java.text.SimpleDateFormat; import java.util.Date; /** * 定义私有属性: * String name; * int age; * ...

  5. String类比较,String类运算比较,String运算

    String类比较,String类运算比较 >>>>>>>>>>>>>>>>>>>&g ...

  6. C# 读取Text文本,写入Text文本

    //读取 private void showMess() { this.dataGridViewX2.Rows.Clear(); //将车辆信息一行行添加到datagreatview 里面 Strea ...

  7. Hardcoded string "下一步", should use @string resource警告 (转载)

    转自:http://blog.csdn.net/iqv520/article/details/7579513 在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string &quo ...

  8. WHY IE AGAIN? - string.charAt(x) or string[x]?

    近期今天在写一个"删除字符串中反复字符串"的函数,代码例如以下: 开门见山,重点 string.charAt(index) 取代 string[index] function re ...

  9. 关于java String类的getBytes(String charsetName)和String(byte[] bytes, String charsetName)

    public byte[] getBytes(Charset charset) Encodes this String into a sequence of bytes using the given ...

随机推荐

  1. TOJ 4701 求阴影部分面积

    4701: 求阴影部分面积  本文版权归BobHuang和博客园共有,不得转载.如想转载,请联系作者,并注明出处. Time Limit(Common/Java):1000MS/3000MS     ...

  2. PTA 09-排序3 Insertion or Heap Sort (25分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/676 5-14 Insertion or Heap Sort   (25分) Accor ...

  3. shell的until循环

    until 循环执行一系列命令直至条件为 true 时停止.until 循环与 while 循环在处理方式上刚好相反.一般while循环优于until循环,但在某些时候,也只是极少数情况下,until ...

  4. 数据库基础之一--DDL(数据库定义语言),DCL(数据库控制语言)

    Mysql是一个非常典型的C/S结构的应用模型,所以Mysql连接必须依赖于一个客户端或者驱动. 在linux中支持两种连接模式:TCP/IP模式和socket SQL语句的四部分: DDL:数据定义 ...

  5. 【Luogu】P3856公共子串(DP)

    题目链接 DP.设last[i][j]是第i个串字符'j'所在的最后的位置,f[i][j][k]是第一个串匹配到i,第二个串匹配到j,第三个串匹配到k,最多的公共子串数. 那么我们三重循环i.j.k, ...

  6. 【Luogu】P2324骑士精神(IDA*)

    题目链接 当guess>limit-deep的时候return就好了. guess是估价函数,值为不在自己地盘上的骑士个数.limit是本次迭代阈值.deep是已经走了多少步. 这个优化是显然的 ...

  7. 【Luogu】P3627抢掠计划(缩点最短路)

    题目链接在此 有环当然一定尽量走环,这是搞缩点的人都知道的常识. 建了新图之后搞点权SPFA跑最长路.枚举每个酒吧选择最大值. 发现我的博客写的越来越水了 #include<cstdio> ...

  8. 【Luogu】P1410子序列(DP)

    题目链接 我DP是真的菜啊啊啊啊啊! f[i][j]表示考虑前i个数,有i-j+1个数组成一个上升子序列,且不以i结尾的尾端最小值. 设a为j个数组成的序列,且以i结尾:b为i-j+1个数组成的序列, ...

  9. BZOJ2654 tree 【二分 + 最小生成树】

    题目 给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有need条白色边的生成树. 题目保证有解. 输入格式 第一行V,E,need分别表示点数,边数和需要的白色边数. 接下来E行, ...

  10. bzoj2324 [ZJOI2011]营救皮卡丘 费用流

    [ZJOI2011]营救皮卡丘 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 2653  Solved: 1101[Submit][Status][D ...