zoukankan      html  css  js  c++  java
  • 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");
  • 相关阅读:
    Linux 内核编码风格
    三种批量插入数据的方法
    一次清除SQL SERVER错误日志的体会!
    打开潘多拉的魔盒——软件设计过程(1)——序
    bloom特效
    wcf基础知识之端口共享 portSharing
    高质量代码(一)
    Luence使用IKAnalyzer分词实例 及 IKAnalyzer扩展词库
    通过什么来衡量C# Socket服务的效能
    iOS开发进阶之静态链接库
  • 原文地址:https://www.cnblogs.com/melody-emma/p/4930733.html
Copyright © 2011-2022 走看看