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 ...
随机推荐
- 图论trainning-part-1 F. Highways
F. Highways Time Limit: 1000ms Memory Limit: 10000KB 64-bit integer IO format: %lld Java class ...
- Flutter 发布APK时进行代码/资源混淆的坑
Flutter 发布APK时进行代码/资源混淆的坑 @author ixenos 1. 关键点 proguard是Java的代码混淆工具,但是当用第三方库的时候,必须要告诉proguard不要检查,因 ...
- hdu6071[最短路+解不等式] 2017多校4
求出所有,从2走到x所需的花费在对 t = 2*min(d1,2, d2,3) 模运算下, 所有剩余系的最短路即可(把一个点拆成 t 个点, 每个点代表一种剩余系), 知道了所有剩余系就可以凑出答案 ...
- HDU——2444The Accomodation of Students(BFS判二分图+最大匹配裸题)
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- [NOI2001] 食物链 (扩展域并查集)
题目描述 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A 吃 B,B 吃 C,C 吃 A. 现有 N 个动物,以 1 - N 编号.每个动物都是 A,B,C 中的一种,但是我 ...
- 洛谷 [T21776] 子序列
题目描述 你有一个长度为 \(n\) 的数列 \(\{a_n\}\) ,这个数列由 \(0,1\) 组成,进行 \(m\) 个的操作: \(1\ l\ r\) :把数列区间$ [l,r]$ 内的所有数 ...
- 深入探究Java中hashCode()和equals()的关系
目录 一.基础:hashCode() 和 equals() 简介 equals() hashCode() 二. 漫谈:初识 hashCode() 与 equals() 之间的关系 三. 解密:深入理解 ...
- Ryuji doesn't want to study (树状数组)
[传送门]:https://nanti.jisuanke.com/t/31460 [题意]给定一个数组a[N],有两种操作, 操作1,给定 l , r, 查询a[l]×L+a[l+1]×(L−1)+ ...
- BZOJ——1607: [Usaco2008 Dec]Patting Heads 轻拍牛头
http://www.lydsy.com/JudgeOnline/problem.php?id=1607 Time Limit: 3 Sec Memory Limit: 64 MBSubmit: 2 ...
- install Python 2.7 and Python 3.3 on CentOS 6
来自:http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/ In this guide I will show you ...