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 ...
随机推荐
- Leetcode 413.等差数列划分
等差数列划分 如果一个数列至少有三个元素,并且任意两个相邻元素之差相同,则称该数列为等差数列. 例如,以下数列为等差数列: 1, 3, 5, 7, 9 7, 7, 7, 7 3, -1, -5, -9 ...
- Codeforces Round #305 (Div. 2) D. Mike and Feet
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- annotation之@Autowired、@Inject、@Resource三者区别
一.@Autowired 1.@Autowired是spring自带的注解,通过‘AutowiredAnnotationBeanPostProcessor’ 类实现的依赖注入: 2.@Autowire ...
- spring之lazy-init
lazy-init:延迟实例化 ApplicationContext实现的默认行为就是在启动服务器时将所有singleton bean提前进行实例化.提前实例化意味着作为初始化过程的一部分,appli ...
- uva 11021
题意:有k只麻球,每只活一天就会死亡,临死之前可能会生出一些新的麻球.具体来说,生i个麻球的概率为pi.给定m,求m天后所有麻球死亡的概率.注意,不足m天时就已经全部死亡的情况也算在内. 分析:由于每 ...
- poj 2115 二元一次不定方程
C Looooops Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14765 Accepted: 3719 Descr ...
- Mato的文件管理(bzoj 3289)
Description Mato同学从各路神犇以各种方式(你们懂的)收集了许多资料,这些资料一共有n份,每份有一个大小和一个编号.为了防止他人偷拷,这些资料都是加密过的,只能用Mato自己写的程序才能 ...
- bootstrap-datatables
刚写到datatimepicker的时候想到这个问题. 这可以说是我接触到的第一个功能如此齐全的一款依赖型插件.我把依赖于别人库的插件这么称呼. 首先上官网:http://datatables.clu ...
- Java并发编程实战 读书笔记(二)
关于发布和逸出 并发编程实践中,this引用逃逸("this"escape)是指对象还没有构造完成,它的this引用就被发布出去了.这是危及到线程安全的,因为其他线程有可能通过这个 ...
- systemtap-note-6-userspace-stack-backtrace
http://nanxiao.me/systemtap-note-6-userspace-stack-backtrace/