scrollTo(String text) and scrollToExact(String text) method of Android Driver not working
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的更多相关文章
- "text"和new String("text")的区别
转自:What is the difference between “text” and new String(“text”)? new String("text"); expli ...
- Hadoop: Text类和String类的比较
一般认为Text类和String类是等价的,但二者之间其实存在着不小差别: 以<Hadoop权威指南>中的案例为例,给定字符串 String s = "\u0041\u00DF ...
- 解决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'). 如图, ...
- 定义私有属性: *String name; * int age; * String gender; * int salary; Date hiredate;//入职时间
import java.text.SimpleDateFormat; import java.util.Date; /** * 定义私有属性: * String name; * int age; * ...
- String类比较,String类运算比较,String运算
String类比较,String类运算比较 >>>>>>>>>>>>>>>>>>>&g ...
- C# 读取Text文本,写入Text文本
//读取 private void showMess() { this.dataGridViewX2.Rows.Clear(); //将车辆信息一行行添加到datagreatview 里面 Strea ...
- Hardcoded string "下一步", should use @string resource警告 (转载)
转自:http://blog.csdn.net/iqv520/article/details/7579513 在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string &quo ...
- WHY IE AGAIN? - string.charAt(x) or string[x]?
近期今天在写一个"删除字符串中反复字符串"的函数,代码例如以下: 开门见山,重点 string.charAt(index) 取代 string[index] function re ...
- 关于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 ...
随机推荐
- Python内置函数6
Python内置函数6 1.license() 输出当前python 的license信息 A. HISTORY OF THE SOFTWARE ========================== ...
- C#-dynamic参考
dynamic 类型的作用是绕过编译时类型检查,改为在运行时进行解析. dynamic 类型简化了对 COM API(例如 Office Automation API).动态 API(例如 IronP ...
- mysql通过mysqldump实现备份,脚本编写
每日三点同步mysql备份任务 crontab -e 0 3 * * * sh /home/shell/mysql_bakup.sh >> /dev/null 2>&1 my ...
- iOS控件-3级城市列表-plist版
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- 【Luogu】P1586四方定理(DP)
题目链接 此题使用DP.设f[i][j]表示数i用j个数表示,则对于所有的k<=sqrt(i),有 f[i][j]=∑f[i-k*k][j-1] 但是这样会有重复情况.所以先枚举k,再枚举i和j ...
- NOJ——1642简单的图论问题?(BFS+优先队列)
[1642] 简单的图论问题? 时间限制: 5000 ms 内存限制: 65535 K 问题描述 给一个 n 行 m 列的迷宫,每个格子要么是障碍物要么是空地.每个空地里都有一个权值.你的 任务是从找 ...
- 【单调队列+尺取】HDU 3530 Subsequence
acm.hdu.edu.cn/showproblem.php?pid=3530 [题意] 给定一个长度为n的序列,问这个序列满足最大值和最小值的差在[m,k]的范围内的最长子区间是多长? [思路] 对 ...
- HDU5056 BoringCount--线性扫一遍
11754936 2014-09-29 10:08:45 Accepted 5056 31MS 392K 1257 B G++ czy 好简单的思路,怎么就没想到呢..... Boring count ...
- hdu3078 建层次树+在线LCA算法+排序
题意:n个点,n-1条边构成无向树,每个节点有权,Q次询问,每次或问从a->b的最短路中,权第k大的值,/或者更新节点a的权, 思路:在线LCA,先dfs生成树0,标记出层数和fa[](每个节点 ...
- poj 3461 hash解法
字符串hash https://blog.csdn.net/pengwill97/article/details/80879387 https://blog.csdn.net/chaiwenjun00 ...