简体   繁体   中英

Scroll and click - Not working for both Android and iOS on Appium tool with selenium java

I am trying to scroll and its not working for both Android and iOS, Can you please help me on this.

Look forward to hear back from you.

Did try with ScrollTO and ScrollToExact as both of them are deprecated now, so did try with this:

        String str = "CADILLAC";
        driver.findElementByAndroidUIAutomator("new UiScrollable(new  UiSelector().scrollable(true).instance(0)).scrollIntoView(new  UiSelector().textContains(\""+str+"\").instance(0))").click();

Still does not work.

Did go through many blogs , videos , course content and material no one has explained or there a specific solution on how to handle this

Did try with below,still gets the error

org.openqa.selenium.WebDriverException:

driver.findElementByAndroidUIAutomator("UiSelector().resourceId(\"current_value_tv\").text(\"All Makes\")").click();
driver.findElementByAndroidUIAutomator("UiSelector().className(\"android.widget.TextView\").text(\"AUSTIN HEALEY\")").click();

org.openqa.selenium.WebDriverException: An unknown server-side error
occurred while processing the command. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 45 milliseconds Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35' System info: host: 'NCA1026471', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91' Driver info: io.appium.java_client.android.AndroidDriver Capabilities [{app=C:\\Appium\\workspace\\Lokesh\\app\\app-release.apk,
appPackage=au.com.carsguide, rotatable=true, networkConnectionEnabled=true, noReset=true, warnings={}, handlesAlerts=true, deviceName=Carsguide Product, version=0.17.0, platform=ANDROID, appActivity=au.com.carsguide.activity.HomeActivity, desired= {app=C:\\Appium\\workspace\\Lokesh\\app\\app-release.apk, appPackage=au.com.carsguide, appActivity=au.com.carsguide.activity.HomeActivity, noReset=true, platformVersion=5.0, browserName=, platformName=Android, deviceName=Carsguide Product, device=Android}, acceptSslCerts=true, platformVersion=21, automationName=selendroid, browserName=selendroid, takesScreenshot=true, javascriptEnabled=true, platformName=android, device=Android}] Session ID: e90cac4d-38aa-99fd-2dd2-70cc09a0e717 *** Element info: {Using=-android uiautomator, value=UiSelector().resourceId("current_value_tv").text("All Makes")} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

you can try this below code, i was trying this code on settings page..

AppiumDriver driver = new AndroidDriver(new URL(""), cap1);

driver.scrollTo("About phone");

Pass the String which is present in the bottom of your app page.

driver.scrollTo("Enter your value");

Use appropriate wait Statements.

use driver.swipe instead of driver.scroll

http://automationbyharsh.blogspot.in/

visit this blog to get full documentation of swipe method for Android and IOS.

scrollTO method is not consistent in appium for android apps. so try the following. go till model listing page

try the below code snippet , This was for flipkart app it may help you with your app

driver.findElementById("com.flipkart.android:id/search_autoCompleteTextView").sendKeys("Reebok Shoes" +"\\n"); Thread.sleep(8000);

    Dimension size = driver.manage().window().getSize();
    System.out.println(size);

    int Starty=(int)(size.height*0.90);
    int Endy=(int)(size.height*0.10);

    int Startx=(int)(size.width*0.50);


    WebElement ele_item = driver.findElementByClassName("android.widget.TextView");
    Thread.sleep(3000);
    do
    {

        List<WebElement> ele_item2 = driver.findElementsByXPath("//*[@index='2'][@text='Reebok SPEED XT Running Shoes'][@class='android.widget.TextView']");
        int size2 = ele_item2.size();
        System.out.println(size2);

        if(size2>0)
        {
            driver.findElementByXPath("//*[@index='2'][@text='Reebok SPEED XT Running Shoes'][@class='android.widget.TextView']").click();
            break;
        }


        driver.swipe(Startx, Starty, Startx, Endy, 1000);
        Thread.sleep(2000);

    } while(ele_item.isDisplayed()==true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM