{"id":10354,"date":"2023-03-02T12:11:00","date_gmt":"2023-03-02T17:11:00","guid":{"rendered":"https:\/\/www.redline13.com\/blog\/?p=10354"},"modified":"2023-06-22T14:18:47","modified_gmt":"2023-06-22T18:18:47","slug":"selenium-basics-on-redline13","status":"publish","type":"post","link":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/","title":{"rendered":"Selenium Basics for Load Testing"},"content":{"rendered":"<p><a id=\"post-10354-_kwcwf53s3vv1\"><\/a> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-10355\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2023\/03\/word-image-10354-1.png\" alt=\"Selenium Basics for Load Testing\" width=\"400\" height=\"300\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2023\/03\/word-image-10354-1.png 400w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2023\/03\/word-image-10354-1-300x225.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>We have several examples available to help you get started with <a href=\"https:\/\/www.selenium.dev\/documentation\/webdriver\/\">Selenium WebDriver<\/a> testing on RedLine13. In this brief post, we\u2019ll go about constructing a Selenium script from scratch. We will also review the basic necessities and also common pitfalls when deploying on RedLine13.<\/p>\n<p>Selenium supports several languages for scripting, with JavaScript being a popular choice. The first line in our script should be instantiating the redline WebDriver instance:<\/p>\n<pre><span style=\"color: #800000;\"><strong>const redline = require('redline13-webdriver');<\/strong><\/span><\/pre>\n<p>We will want to define a constant for the <a href=\"https:\/\/www.selenium.dev\/documentation\/webdriver\/browsers\/\">browser<\/a> type that we want to use. The recommended browser for RedLine13 is <em>Chrome<\/em>, however <em>Mozilla FireFox<\/em> is also supported. Here we define the browser we will use as <em>Chrome<\/em>:<\/p>\n<pre><span style=\"color: #800000;\"><strong>const BROWSER = 'chrome';<\/strong><\/span><\/pre>\n<p>Next we will want to define our <code><span style=\"color: #800000;\"><strong>main()<\/strong><\/span><\/code> method. As the name suggests, this is where the main logic of the test will run:<\/p>\n<pre><span style=\"color: #800000;\"><strong>const main = () =&gt; {\n<\/strong><strong>    ...<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>};<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>main();<\/strong><\/span><\/pre>\n<p><span style=\"font-size: revert; color: initial;\">Inside the main function, the first thing we will want to do is define the actual <\/span><em style=\"font-size: revert; color: initial;\">WebDriver<\/em><span style=\"font-size: revert; color: initial;\"> object. This can be set as follows:<\/span><\/p>\n<pre><span style=\"color: #800000;\"><strong>const driver = redline.loadBrowser(BROWSER);<\/strong><\/span><\/pre>\n<p>Now let\u2019s do something useful by defining the main actions of our script:<\/p>\n<pre><span style=\"color: #800000;\"><strong>driver.get(\u2018https:\/\/demoqa.com\/\u2019).then(_ =&gt; {<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    redline.snap('capture1.png');<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    driver.get(\u2018https:\/\/demoqa.com\/webtables\u2019).then(_ =&gt; {<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>        redline.snap('capture2.png'); <\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    }); <\/strong><\/span>\n<span style=\"color: #800000;\"><strong>});<\/strong><\/span><\/pre>\n<p>In the above example, we instruct <em>WebDriver<\/em> to load an endpoint (<code>https:\/\/demoqa.com\/<\/code>) and once that is loaded, obtain a screen capture. Then it loads another endpoint (<code>https:\/\/demoqa.com\/webtables<\/code>) and performs a second screen capture.<\/p>\n<p>The last statement that should be included in any Selenium script is a call to <span style=\"color: #800000;\"><strong><code><span style=\"color: #800000;\">driver.quit()<\/span><\/code><\/strong><\/span><span style=\"color: #000000;\">.<\/span> This will ensure that the <em>WebDriver<\/em> instance terminates normally and allows for the test to end expectedly.<\/p>\n<p>To put all of the above pieces together, our entire script should appear as follows:<\/p>\n<pre><span style=\"color: #800000;\"><strong>const redline = require('redline13-webdriver');<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>const BROWSER = 'chrome';<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>const main = () =&gt; {<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    const driver = redline.loadBrowser(BROWSER); <\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    driver.get(\u2018https:\/\/demoqa.com\/\u2019).then(_ =&gt; {<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>        redline.snap('capture1.png');<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>        driver.get(\u2018https:\/\/demoqa.com\/webtables\u2019).then(_ =&gt; {<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>            redline.snap('capture2.png'); <\/strong><\/span>\n<span style=\"color: #800000;\"><strong>        }); <\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    });<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>    driver.quit();<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>};<\/strong><\/span>\n<span style=\"color: #800000;\"><strong>main();<\/strong><\/span><\/pre>\n<p>This represents a very simple example of a WebDriver script, however it covers all of the basic concepts required to run such a test on RedLine13. You can expand the body of the <span style=\"color: #800000;\"><strong><code><span style=\"color: #800000;\">main()<\/span><\/code><\/strong><\/span> method to make your script perform more complex tasks to achieve your testing goals.<\/p>\n<h3>JMeter as an Alternative to Selenium<\/h3>\n<p><span style=\"font-weight: 400;\">Even though Selenium WebDriver most closely simulates the end user experience recreating it with high accuracy, it is resource intensive.\u00a0 If we are more concerned with stress testing our target test application we can do this more efficiently with a scripted framework such as <\/span><a href=\"https:\/\/www.redline13.com\/blog\/docs\/jmeter-tests\/\"><span style=\"font-weight: 400;\">JMeter<\/span><\/a><span style=\"font-weight: 400;\">.\u00a0 This is especially true when massively scaled load testing is indicated into the thousands or millions of virtual users and beyond.\u00a0 In these cases, JMeter will almost always be the superior choice.<\/span><\/p>\n<hr \/>\n<p>Did you know that we offer a full-featured free trial? <a href=\"https:\/\/www.redline13.com\/Service\">Sign up now<\/a> and start your Selenium WebDriver testing on RedLine13 today!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have several examples available to help you get started with Selenium WebDriver testing on RedLine13. In this brief post, we\u2019ll go about constructing a Selenium script from scratch. We will also review the basic necessities and also common pitfalls when deploying on RedLine13. Selenium supports several languages for scripting, with JavaScript being a popular choice. The first line in our script should be instantiating the redline WebDriver instance: const redline = require(&#8216;redline13-webdriver&#8217;); We will want<a class=\"more-link\" href=\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\">Read More &rarr;<\/a><\/p>\n","protected":false},"author":11,"featured_media":10355,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,45],"tags":[318,424,456,607,457,523,547],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-dkoziel","4":"post-10354","6":"format-standard","7":"has-post-thumbnail","8":"category-blog","9":"category-selenium","10":"post_tag-load-testing","11":"post_tag-redline13","12":"post_tag-selenium","13":"post_tag-selenium-javascript","14":"post_tag-selenium-webdriver","15":"post_tag-tutorial","16":"post_tag-webdriver"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Selenium Basics for Load Testing - RedLine13<\/title>\n<meta name=\"description\" content=\"In this brief post, we\u2019ll get you started with Selenium WebDriver testing on RedLine13 by walking through creating a test plan from scratch.\" \/>\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.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Selenium Basics for Load Testing - RedLine13\" \/>\n<meta property=\"og:description\" content=\"In this brief post, we\u2019ll get you started with Selenium WebDriver testing on RedLine13 by walking through creating a test plan from scratch.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\" \/>\n<meta property=\"og:site_name\" content=\"RedLine13\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-02T17:11:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-22T18:18:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2023\/03\/word-image-10354-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"David Koziel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"David Koziel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\"},\"author\":{\"name\":\"David Koziel\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20\"},\"headline\":\"Selenium Basics for Load Testing\",\"datePublished\":\"2023-03-02T17:11:00+00:00\",\"dateModified\":\"2023-06-22T18:18:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\"},\"wordCount\":405,\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"keywords\":[\"Load Testing\",\"RedLine13\",\"selenium\",\"Selenium JavaScript\",\"selenium webdriver\",\"tutorial\",\"webdriver\"],\"articleSection\":[\"Blog\",\"Selenium\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\",\"name\":\"Selenium Basics for Load Testing - RedLine13\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\"},\"datePublished\":\"2023-03-02T17:11:00+00:00\",\"dateModified\":\"2023-06-22T18:18:47+00:00\",\"description\":\"In this brief post, we\u2019ll get you started with Selenium WebDriver testing on RedLine13 by walking through creating a test plan from scratch.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.redline13.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Selenium Basics for Load Testing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"name\":\"RedLine13\",\"description\":\"(Almost) Free Load Testing in the Cloud\",\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.redline13.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\",\"name\":\"RedLine13\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"contentUrl\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"width\":300,\"height\":68,\"caption\":\"RedLine13\"},\"image\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20\",\"name\":\"David Koziel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g\",\"caption\":\"David Koziel\"},\"url\":\"https:\/\/www.redline13.com\/blog\/author\/dkoziel\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Selenium Basics for Load Testing - RedLine13","description":"In this brief post, we\u2019ll get you started with Selenium WebDriver testing on RedLine13 by walking through creating a test plan from scratch.","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.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/","og_locale":"en_US","og_type":"article","og_title":"Selenium Basics for Load Testing - RedLine13","og_description":"In this brief post, we\u2019ll get you started with Selenium WebDriver testing on RedLine13 by walking through creating a test plan from scratch.","og_url":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/","og_site_name":"RedLine13","article_published_time":"2023-03-02T17:11:00+00:00","article_modified_time":"2023-06-22T18:18:47+00:00","og_image":[{"width":400,"height":300,"url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2023\/03\/word-image-10354-1.png","type":"image\/png"}],"author":"David Koziel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"David Koziel","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/#article","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/"},"author":{"name":"David Koziel","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20"},"headline":"Selenium Basics for Load Testing","datePublished":"2023-03-02T17:11:00+00:00","dateModified":"2023-06-22T18:18:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/"},"wordCount":405,"publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"keywords":["Load Testing","RedLine13","selenium","Selenium JavaScript","selenium webdriver","tutorial","webdriver"],"articleSection":["Blog","Selenium"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/","url":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/","name":"Selenium Basics for Load Testing - RedLine13","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/#website"},"datePublished":"2023-03-02T17:11:00+00:00","dateModified":"2023-06-22T18:18:47+00:00","description":"In this brief post, we\u2019ll get you started with Selenium WebDriver testing on RedLine13 by walking through creating a test plan from scratch.","breadcrumb":{"@id":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.redline13.com\/blog\/2023\/03\/selenium-basics-on-redline13\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.redline13.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Selenium Basics for Load Testing"}]},{"@type":"WebSite","@id":"https:\/\/www.redline13.com\/blog\/#website","url":"https:\/\/www.redline13.com\/blog\/","name":"RedLine13","description":"(Almost) Free Load Testing in the Cloud","publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.redline13.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.redline13.com\/blog\/#organization","name":"RedLine13","url":"https:\/\/www.redline13.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","contentUrl":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","width":300,"height":68,"caption":"RedLine13"},"image":{"@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20","name":"David Koziel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g","caption":"David Koziel"},"url":"https:\/\/www.redline13.com\/blog\/author\/dkoziel\/"}]}},"_links":{"self":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/10354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/comments?post=10354"}],"version-history":[{"count":7,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/10354\/revisions"}],"predecessor-version":[{"id":10406,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/10354\/revisions\/10406"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media\/10355"}],"wp:attachment":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media?parent=10354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/categories?post=10354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/tags?post=10354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}