{"id":69519,"date":"2019-12-30T16:33:20","date_gmt":"2019-12-30T11:03:20","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=69519"},"modified":"2024-04-12T14:21:51","modified_gmt":"2024-04-12T08:51:51","slug":"executing-session-commands","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/","title":{"rendered":"Session Commands"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/mobile-testing-appium-tutorials\/\" target=\"_blank\" rel=\"noreferrer noopener\">Go back to tutorial<\/a><\/p>\n\n\n<h1><strong>Session Commands<\/strong><\/h1>\n<p>In this section we will be giving an overview about the various session command including creating new session commands, end session commands, and many other capability related commands.<\/p>\n<h3><strong>How to create a new session?<\/strong><\/h3>\n<p>We have illustrated an example showcasing the process to create a new session command &#8211; Using Java<\/p>\n<p>DesiredCapabilities desiredCapabilities = new DesiredCapabilities();<\/p>\n<p>desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, &#8220;10.3&#8221;);<\/p>\n<p>desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, &#8220;iPhone Simulator&#8221;);<\/p>\n<p>desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, &#8220;XCUITest&#8221;);<\/p>\n<p>desiredCapabilities.setCapability(MobileCapabilityType.APP, &#8220;\/path\/to\/ios\/app.zip&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>URL url = new URL(&#8220;http:\/\/127.0.0.1:4723\/wd\/hub&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>IOSDriver driver = new IOSDriver(url, desiredCapabilities);<\/p>\n<p>String sessionId = driver.getSessionId().toString();<\/p>\n<p>&nbsp;<\/p>\n<p>Further, the server must attempt to create a session that most closely matches the desired and required capabilities.<\/p>\n<ul>\n<li>JSONWP Spec &#8211; In this case required capabilities have higher priority than desired capabilities and must be set for the session to be created<\/li>\n<li>W3C Spec capabilities.alwaysMatch must be set for session to be created; capabilities.firstMatch must match at least one (such that the first one to match will be used)<\/li>\n<\/ul>\n<h3><strong>How to end a session?<\/strong><\/h3>\n<p>We will now illustrate how to end a running session &#8211; Using in Java<\/p>\n<p>driver.quit();<\/p>\n<p>Where, <u>HTTP API Specifications<\/u><\/p>\n<p>Endpoint &#8211;<\/p>\n<p>DELETE \/session\/:session_id<\/p>\n<p>URL Parameters &#8211;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"91\">name<\/td>\n<td width=\"188\">description<\/td>\n<\/tr>\n<tr>\n<td width=\"91\">session_id<\/td>\n<td width=\"188\">ID of the session to delete<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>JSON Parameters \u2013 None<\/p>\n<p>Response &#8211; null<\/p>\n<h3><strong>How to get Session Capabilities?<\/strong><\/h3>\n<p>We will illustrate the process to retrieve the capabilities of the specified session &#8211; Using Java<\/p>\n<p>Map&lt;String, Object&gt; caps = driver.getSessionDetails();<\/p>\n<p><u>HTTP API Specifications<\/u><\/p>\n<p>Endpoint &#8211; GET \/session\/:session_id<\/p>\n<p>URL Parameters &#8211;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"319\">name<\/td>\n<td width=\"319\">description<\/td>\n<\/tr>\n<tr>\n<td width=\"319\">session_id<\/td>\n<td width=\"319\">ID of the session to route the command to<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>JSON Parameters &#8211; None<\/p>\n<p>Response &#8211; An object describing the session&#8217;s capabilities (object)<\/p>\n<h3><strong>What is session command to navigate?<\/strong><\/h3>\n<p>We will illustrate the process to navigate backwards in the browser history, if possible (Web context only) &#8211; Using Java<\/p>\n<p>driver.back();<\/p>\n<p><u>HTTP API Specifications<\/u><\/p>\n<p>Endpoint &#8211; POST \/wd\/hub\/session\/:session_id\/back<\/p>\n<p>URL Parameters &#8211;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"319\">name<\/td>\n<td width=\"319\">description<\/td>\n<\/tr>\n<tr>\n<td width=\"319\">session_id<\/td>\n<td width=\"319\">ID of the session to route the command to<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>JSON Parameters &#8211; None<\/p>\n<p>Response &#8211; null<\/p>\n<h3><strong>What are the orientation commands?<\/strong><\/h3>\n<ul>\n<li><strong>Get Orientation &#8211;&nbsp;<\/strong>Get the current device\/browser orientation<\/li>\n<\/ul>\n<p>Example Usage in Java<\/p>\n<p>ScreenOrientation orientation = driver.getOrientation();<\/p>\n<ul>\n<li><strong>Set Orientation &#8211;&nbsp;<\/strong>Set the current device\/browser orientation<\/li>\n<\/ul>\n<p>Example Usage in Java<\/p>\n<p>driver.rotate(ScreenOrientation.LANDSCAPE);<\/p>\n<p>&nbsp;<\/p>\n<p><em>Learn more about device setting and updates!<\/em><\/p>\n<h4><strong>Boost your chances for better job opportunities. Practice and Prepare for <a href=\"https:\/\/www.vskills.in\/certification\/testing\/mobile-testing-appium-professional\">Mobile Testing (Appium) Exam<\/a> Now!<\/strong><\/h4>\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/mobile-testing-appium-tutorials\/\" target=\"_blank\" rel=\"noreferrer noopener\">Go back to tutorial<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go back to tutorial Session Commands In this section we will be giving an overview about the various session command including creating new session commands, end session commands, and many other capability related commands. How to create a new session? We have illustrated an example showcasing the process to create a new session command &#8211;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[7891],"tags":[7963],"class_list":["post-69519","page","type-page","status-publish","hentry","category-mobile-testing-appium","tag-session-commands"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Session Commands - Mobile Testing (Appium) - Vskills Tutorial<\/title>\n<meta name=\"description\" content=\"Learn how to execute session commands and session capabilities. Get ready to qualify and become a Certified Mobile Testing Professional. Prepare Now1\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Session Commands - Mobile Testing (Appium) - Vskills Tutorial\" \/>\n<meta property=\"og:description\" content=\"Learn how to execute session commands and session capabilities. Get ready to qualify and become a Certified Mobile Testing Professional. Prepare Now1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:51:51+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/\",\"name\":\"Session Commands - Mobile Testing (Appium) - Vskills Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2019-12-30T11:03:20+00:00\",\"dateModified\":\"2024-04-12T08:51:51+00:00\",\"description\":\"Learn how to execute session commands and session capabilities. Get ready to qualify and become a Certified Mobile Testing Professional. Prepare Now1\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Session Commands\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Session Commands - Mobile Testing (Appium) - Vskills Tutorial","description":"Learn how to execute session commands and session capabilities. Get ready to qualify and become a Certified Mobile Testing Professional. Prepare Now1","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/","og_locale":"en_US","og_type":"article","og_title":"Session Commands - Mobile Testing (Appium) - Vskills Tutorial","og_description":"Learn how to execute session commands and session capabilities. Get ready to qualify and become a Certified Mobile Testing Professional. Prepare Now1","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:51:51+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/","name":"Session Commands - Mobile Testing (Appium) - Vskills Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2019-12-30T11:03:20+00:00","dateModified":"2024-04-12T08:51:51+00:00","description":"Learn how to execute session commands and session capabilities. Get ready to qualify and become a Certified Mobile Testing Professional. Prepare Now1","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/executing-session-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Session Commands"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/69519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=69519"}],"version-history":[{"count":5,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/69519\/revisions"}],"predecessor-version":[{"id":84565,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/69519\/revisions\/84565"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=69519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=69519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=69519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}