Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
Appium [ Javascript ] [WD] - Scroll to an element which is not visible but enabled or clickable

I am using appium javascript client with uiautomator2 as the automation engine for android. In one of screen having multiple buttons like Button 1, Button 2, Button 3 ...etc stacked horizantal with scroll. However, only first two buttons will be visible on page load [ Refer Screen shot].

I want to click on button 4. Have implemented below code to handle scroll and click button but I am unable to break loop since attribute is always false.

            var element = await driver.elementByXPath("//android.widget.Button[contains(@text,'Button 4')]");
            var scrollFromElement = await driver.elementByXPath("//android.widget.Button[contains(@text,'Button 2')]");

            var isEleFocused = await element.getAttribute("focused");
            console.log("concierge element is Focused - " + isEleFocused);

            if (isEleFocused == "false")
            {
                var i = 0;
                do{
                    await swipeElementAndroid(scrollFromElement, "RIGHT")
                    var d1 = await element.getAttribute("focused");
                    if(d1 == "true"){
                        i=10
                        break;
                    }
                    else{
                        await swipeElementAndroid(scrollFromElement, "RIGHT")
                        i=i+1
                        console.log("i="+i)
                    }   
                }while(i<5)
            }       
            
            await sleepwait(500)
            console.log("after scroll- if condition")

            e1 = await driver.elementByXPath("//android.widget.Button[contains(@text,'Button 4')]")
            await e1.click()

Kindly suggest alternative way to handle the same.

Note: Attributes like displayed, clickable are always true even though button is not visible.

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!