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. springboot集成redis操作

    使用HashOperations操作redis----https://www.cnblogs.com/shiguotao-com/p/10560458.html 使用HashOperations操作r ...

  2. NYOJ 814 又见拦截导弹

    又见拦截导弹 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 大家对拦截导弹那个题目应该比较熟悉了,我再叙述一下题意:某国为了防御敌国的导弹袭击,新研制出来一种导弹拦 ...

  3. 九度oj 题目1254:N皇后问题

    题目描述: N皇后问题,即在N*N的方格棋盘内放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在同一斜线上.因为皇后可以直走,横走和斜走如下图). 你的任务是,对 ...

  4. 14-new和this

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  5. oracle用户密码错误导致用户锁定

    解决方法:使用DBA用户将其解锁: SQL> alter user ecology account unlock; 用户已更改. 用户密码限制设置: 查看FAILED_LOGIN_ATTEMPT ...

  6. 【Luogu】P1352没有上司的舞会(树形DP)

    题目链接 设f[i][0]表示第i个人不去舞会时子树的最大欢乐度,f[i][1]表示第i个人去舞会时子树的最大欢乐度. 则有状态转移方程:f[i][0]+=∑max(f[to][0],f[to][1] ...

  7. leetcode 350

    找两个数组的交叉部分,可以用map进行标记 首先对第一个数组进行记录,第二个数组在第一个数组记录基础上进行判断,如果在第一个数组出现过,就记录 class Solution { public: vec ...

  8. PatentTips - Optimizing Write Combining Performance

    BACKGROUND OF THE INVENTION The use of a cache memory with a processor facilitates the reduction of ...

  9. maven自动导入包失败

    pom.xml文件依赖添加后,让maven自动导入包,老是失败,文件夹中有其他文件,就是缺少jar文件 解决: // 进入pom.xml所在的文件夹,执行下面的命令,下载jar包 mvn -f pom ...

  10. iscroll API

    概况 资料来源 http://cubiq.org/iscroll-4 http://www.cnblogs.com/wanghun/archive/2012/10/17/2727416.html ht ...