Performing Scrolling and Swiping in Appium using PointerInput in Java

Scrolling and swiping are important gestures in mobile app testing using Appium. These gestures allow you to interact with your app and test its functionality. The PointerInput class in Java provides a powerful way to perform these gestures using Appium. In this post, we'll show you how to use PointerInput to perform scrolling and swiping in Appium with Java.

What is PointerInput?

PointerInput is a class in the Java client library for Appium that provides a way to perform gestures like tap, swipe, and scroll. It's a low-level API that allows you to create custom gestures using pointer events. With PointerInput, you can create complex gestures that are not possible with the standard Appium API.

How to Perform Scrolling and Swiping using PointerInput

To perform scrolling or swiping in Appium using PointerInput, you need to follow these steps:

  1. Create a new PointerInput instance.
  2. Create a new sequence for the gesture.
  3. Add actions to the sequence for the starting point, move, and release.
  4. Use the Appium driver to perform the sequence on the device.

Here's an example of how to perform scrolling and swiping using PointerInput in Appium with Java:

 
// create a new PointerInput instance
PointerInput pointerInput = new PointerInput(PointerInput.Kind.TOUCH, "finger1");
// create a new sequence
Sequence sequence = new Sequence(pointerInput, 0);
// create a move action for the starting point
PointerMoveAction moveAction1 = pointerInput.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), x1, y1);
// create a press action for the starting point
PointerDownAction downAction = pointerInput.createPointerDown(PointerInput.MouseButton.LEFT.asArg());
// add the move and press actions to the sequence
sequence.addAction(moveAction1);
sequence.addAction(downAction);

// create a move action for the ending point
PointerMoveAction moveAction2 = pointerInput.createPointerMove(Duration.ofMillis(1000), PointerInput.Origin.viewport(), x2, y2);
// create a release action for the ending point
PointerUpAction upAction = pointerInput.createPointerUp(PointerInput.MouseButton.LEFT.asArg());
// add the move and release actions to the sequence
sequence.addAction(moveAction2);
sequence.addAction(upAction);

// perform the sequence action
driver.perform(Arrays.asList(sequence));

In this example, we create a new PointerInput instance and use it to create a sequence that contains a press, move, and release action for performing scrolling or swiping. We then use the perform method of the Appium driver to execute the sequence on the device.

Conclusion

In this post, we showed you how to perform scrolling and swiping in Appium using PointerInput in Java. By using PointerInput, you can create complex gestures that are not possible with the standard Appium API. With this knowledge, you can improve your mobile app testing and ensure that your app functions as expected. 

READ COMPLETE POST...




StaleElementReferenceException is a common issue encountered when using Selenium Java to automate web testing. This exception occurs when a web element on a page becomes stale or is no longer valid or available in the Document Object Model (DOM).


To handle this exception effectively in your Selenium Java test scripts, you can follow these steps:


Identify the web element causing the StaleElementReferenceException.

Wrap the code interacting with the element in a try-catch block.

In the catch block, wait for the element to become available again and retry the operation.

Here's an example of how you can handle the StaleElementReferenceException in Selenium Java:


WebElement element = driver.findElement(By.id("my-id"));

try {

    element.click();

} catch (StaleElementReferenceException e) {

    // Wait for the element to become available again

    WebDriverWait wait = new WebDriverWait(driver, 10);

    element = wait.until(ExpectedConditions.elementToBeClickable(By.id("my-id")));

    // Retry the operation

    element.click();

}

By using this approach, you can ensure that your Selenium Java scripts will handle StaleElementReferenceException gracefully and recover from it, thereby making your web testing more robust and reliable.

READ COMPLETE POST...




 Are you looking for a powerful tool to automate browser testing? Look no further than Playwright. With its user-friendly API and support for multiple browser engines, including Chromium, Firefox, and Webkit, Playwright makes it easy to interact with web pages and automate browser interactions.

One of the main benefits of using Playwright is its built-in support for headless execution, making it ideal for running tests in a continuous integration environment. It also has support for browser contexts, enabling the running of multiple pages in the same browser instance, and the browser DevTools protocol, allowing for interaction with the browser's debugging features.

But Playwright offers more than just automated testing capabilities. It also has built-in support for handling browser events such as clicks, inputs, and navigation. You can also take screenshots, record videos, and generate performance metrics for debugging and monitoring web apps. Plus, it even supports parallel testing to speed up the testing process.

The Playwright API also provides a powerful set of tools for interacting with web pages, including the ability to query and manipulate the DOM, fill in form fields, upload files, and perform other common web interactions. Plus, the library is written in JavaScript and TypeScript, making it easy for developers to write automation scripts and integrate with popular test runners such as Jest and Mocha.


In short, Playwright offers a comprehensive solution for automating browser testing. Its user-friendly API, support for multiple browser engines, and integration with popular test runners make it a versatile and powerful tool for developers. So, why Playwright? Because it simply makes automating browser testing a breeze.

READ COMPLETE POST...




 1. Retrieve the test data from the excel sheet, put it in the google search bar, click on the search button and click on the first link opened in google search.

2. Write a program to check whether the string can be a palindrome. for example if the string aab(it is not a palindrome string). replace the characters in a string like aba, baa, etc., and check that can be a palindrome string.

3. How will you Identify the web element that has the same property values?

4. write a program to return the no of rows and columns in a web table?

5. Write a program to return the row and column value like(3,4) for a given date in a web table?


READ COMPLETE POST...




PWC Bangalore Interview Questions for QA/Test/ SDET (Selenium and Java)

JAVA

1. what is polymorphism? types of polymorphism?

2.Access Modifiers(Private,public,protected)

3. Object life cycle architecture?

4.singleTON Class?

5. Innerclass &Anonymous class?

6. how to print without the main method "hello"?

7. Method overloading & overriding & Inheritance?

Selenium

1. what is the selenium web driver? advantage of against RC, IDE?

2. How to handle javascript popup?

3. How to handle iframes?

4. how to handle file download popup?

5. what is the use of TestngListeners?

6. what is POM.XML?

7. what is ant & use in the framework?


READ COMPLETE POST...




WALMART Bangalore QA TEST SDET Interview Questions 

1st Round Technical :

1. Find the sum of both diagonals from a 2D n*n

matrix.

2. Reverse a string using recursion.

3. Find character count using string inbuilt methods

you can use max two methods. (Sol :

string.length() & replaceAll(given char).

4. Implement ArrayList using Array, Coverall

exceptions, and boundary cases.

5. Singly LinkedList reverse.

6. Find Nth node from the end of a LinkedList.

7. Selenium Web Table questions using ArrayList.

8. Selenium drop-down duplicate find and remove

using HashMap.

9. Explain the Design pattern of the Actions class.

10. Why Page Object Model?

11. Explain the current framework and questions

around.

12. Write program for Java JDBC connection

(Sudo code).

13. Explain TestNG annotations.

14. Explain Java Oops concepts.

15. Java output codes for Polymorphism; static

keywords; Inheritance.

16. Use of Custom Exceptions, Explain.

17. Explain Rest API architecture.

18. All API status codes meanings and conditions with test data.

19. Explain API framework & questions around it.

20. Json Handling; using parsers & POJO.

2nd Round Technical :

1. Java code for All permutations of all elements

from an integer array.

2. Java program to find a number from an array

whose all left elements are smaller & all right

elements are greater.

3. Selenium xpaths: axes (siblings ......)

4. How selenium code invokes browsers using

Factory Design pattern.

5. Java HashMap internal architecture.

6. Occurrence of each character of a String.

7. All iteration methods of HashMap.

8. More questions of Json response complex or nested Jsons.

READ COMPLETE POST...




 How to handle alerts?

Ans: driver.switchTo().alert() - >> .accept(); I dismiss(); I getText(); I sendKeys("Message");, How to take screenshots? Ans:

File screenshot = ((TakesScreenshot) driver).getScreenshotAs(Output Type.FILE);

FileUtils.copyFile(screenshot, new File("".// screenshot/" + fileName));

What is actions class? Write the syntax for it.

3 How to capture broken links? What are the different types of waits? Can you write syntax for Implicit and Explicit wait? Ans:

driver.manage().timeouts().implicitlyWait (imp licitWait, TimeUnit. SECONDS); WebDriverWait explicit Wait = new WebDriverWait (driver, 10); explicitWait.until( Expected Condition

s.visibilityOfElementLocated(By.xpath("//span[contains(text();'applied ..!')]'))); Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).with Timeout(Durat ion.of Seconds(30)) .pollingEvery(Duration.of Seconds (3)).ignoring (NoSuch Element Exception.class);

Scripts execution in HEADLESS mode? How many ways it is possible? Ans:

ChromeOptions options = new ChromeOptions(); options.addArguments("headless"); WebDriverManager.chromedriver().setup(); driver = new Chrome Driver(options);

Desired Capabilities? Write down the syntax? Ans:

setCapabilities and addArguements?

Write data (with Columns) using Apache POI?

How many Meetings in Agile? Ans: Daily Scrum, Sprint planning, Sprint retrospective, Backlog Refinement/Grooming

You are the only Automation resource in your project, What would be your approach?

Are you able to design the framework from scratch?

Cucumber -> Feature file, Steps, and how to run the test cases?

Ans: Cucumber is a testing tool that supports Behavior Driven Development (BDD). It offers a way to write tests that anybody can understand, regardless of their technical knowledge

READ COMPLETE POST...


 
HOME | Freshers | Exp | Java | SQL | Walkins | OffCampus | BankJobs
=*= PRIVACY POLICY And DISCLAIMER =*=
Some of the stuff contained this site are found on internetThis site is not responsible for publishing all available Information as well accuracy, please check posted Information with its original sources, e.g. News Papers/ Websites etc.We collect all the Information form the Internet.
Software My Zimbio
Copyright © 2013 Career+ Blog +Google | Disclaimer | Privacy Policy | Contact