How to Start and Stop Appium Server Programmatically | Appium Tutorials

Опубликовано: 06 Август 2024
на канале: Azhar Techno Coder
236
28

How to Start and Stop Appium Server Programmatically | Appium Tutorials

Code:
public static AppiumDriverLocalService service;
public static AppiumServiceBuilder builder;


public static void startServer() throws MalformedURLException {

//Build the Appium service
builder = new AppiumServiceBuilder();
builder.withIPAddress("127.0.0.1");
builder.usingPort(4723);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL,"error");

//Start the server with the builder
service = AppiumDriverLocalService.buildDefaultService();
service.start();
}

public static void stopServer() {
if (service != null && service.isRunning()) {
service.stop();
}
}

public static boolean checkIfServerIsRunnning(int port) {

boolean isServerRunning = false;
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(port);
serverSocket.close();
} catch (IOException e) {
//If control comes here, then it means that the port is in use
isServerRunning = true;
} finally {
serverSocket = null;
}
return isServerRunning;
}

Next Steps :

---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists

► 1. Javascript -    • Javascript Factory  
► 2. Puppetter -    • Puppeteer  
► 3. Cypress -    • Cypress  
► 4. Tech works -    • Video  
► 5. Vbscript Basics To Advanced -    • VBScript Part 1 -  Features Advantage...  
► 6. Jmeter -    • Jmeter Tutorials  
► 7. Excel -    • Videos On Excel  
► 8. Appium -    • Appium  
► 9. Shares -    • Shares  
► 10. Javascript Interview Questions -   • Javascript Interview Questions  
► 11. C# Tutorials -    • C# Factory  
► 12. HTML & CSS -    • HTML & CSS  
► 13. Browser Console -    • Browser Console  
► 14. JSON -    • Videos on Json  
► 15. Specflow -    • Specflow Tutorials  
► 16. MongoDB -    • MongoDB Tutorials  
► 17. Postman -    • Postman  
► 18. Python -    • Python  
► 19. Typescript -    • Typescript & Node Imp Questions  
► 20. Node -    • Node  
► 21. Java Selenium Interview Questions:    • Java and Selenium Imp  
► 22. Real Time Interview Q & A:    • Real Time Interview Questions  
► 23.SOAP UI Tutorials :   • SOAP UI  
► 24. WebDriverIO :    • Getting Started with WebdriverIO | In...  
► 25. Jenkins :   • How to download and install Jenkins o...  
► 26. Cloud and CyberSecurity :    • What is Windows Sandbox? How to enabl...  
► 27. GitHub :   • How to upload Files / Folders in GitH...  
► 28. Videos on Ubuntu :    • Videos on Ubuntu / Linux  
► 29. Videos on Beyond Jira :    • Beyond Jira Tutorials  
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------

#appium
#appiumserver
#java