Session commands in Appium



Session commands in Appium

Create New Session

Create a new session.

The server should attempt to create a session that most closely matches the desired and required capabilities.

DriverOptions cap = new AppiumOptions();

//Samsing galaxy S9 emulator –Native app
string appPath = @”C:\ADB\ApiDemos-debug.apk”;
cap.AddAdditionalCapability(MobileCapabilityType.DeviceName, “Samsung Galaxy S9”);
cap.AddAdditionalCapability(MobileCapabilityType.PlatformName, “Android”);
cap.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, “8.0.0”);
cap.AddAdditionalCapability(MobileCapabilityType.Udid, “192.168.219.103:5555”);
cap.AddAdditionalCapability(MobileCapabilityType.App, appPath);
//cap.AddAdditionalCapability(“appPackage”, “io.appium.andriod.apis”);

driver = new AndroidDriver(new Uri(“http://127.0.0.1:4723/wd/hub”), cap, TimeSpan.FromSeconds(60));

String sessionId = driver.SessionId().toString(); //Get the sessionid

End Session

End the running session

driver.Quit();

Get Session Capabilities

Retrieve the capabilities of the specified session

ICapabilities caps = driver.Capabilities;

Go Back

Navigate backwards in the browser history, if possible (Web context only)

driver.Navigate().Back();

Take Screenshot

Take a screenshot of the current viewport/window/page

Screenshot screenshot = driver.GetScreenshot();

Get Page Source
Get the current application hierarchy XML (app) or page source (web)

string pageSource = driver.PageSource;

Set Timeouts

Configure the amount of time that a particular type of operation can execute for before they are aborted.

The types of timeouts are ‘page load’, ‘script’ and ‘implicit’. (The example usage is just ‘page load’)

driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);

Get available log types
Get available log types as a list of strings.
IReadOnlyCollection<> logTypes = driver.Manage().Logs.AvailableLogTypes;
Get Logs
Get the log for a given log type. Log buffer is reset after each request.
ILogs logs = driver.Manage().Logs;

Tags: , , , , , ,
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!

https://bridgejunks.com/ https://crownmakesense.com/ https://brithaniabookjudges.com/ https://hughesroyality.com/ https://rhythmholic.com/ https://bandar89.simnasfikpunhas.com/ https://www.100calshop.co.il/products/thailand/ https://myasociados.com/ https://solyser.com/ http://konfidence.cz/ https://muscadinepdx.com/ https://bandar89.parajesandinos.com.ve/ https://goremekoop.com/ https://oncoswisscenter.com/ https://www.turunclifehotel.com/bandar89/ https://www.houseofproducts.biz/ https://taimoormphotography.com/
BIJI18 BIJI18 BIJI18