<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vijay Jdk on Medium]]></title>
        <description><![CDATA[Stories by Vijay Jdk on Medium]]></description>
        <link>https://medium.com/@vijay.jdk?source=rss-710e1a88eb5f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GW73TSAsxa8UCxkN</url>
            <title>Stories by Vijay Jdk on Medium</title>
            <link>https://medium.com/@vijay.jdk?source=rss-710e1a88eb5f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:26:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vijay.jdk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Protractor vs Selenium WebDriverJS Competitors or Companion...]]></title>
            <link>https://medium.com/@vijay.jdk/protractor-vs-selenium-webdriverjs-competitors-or-companion-b4546269d392?source=rss-710e1a88eb5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4546269d392</guid>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[protractor]]></category>
            <dc:creator><![CDATA[Vijay Jdk]]></dc:creator>
            <pubDate>Wed, 11 Dec 2019 04:47:26 GMT</pubDate>
            <atom:updated>2019-12-11T04:47:26.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*H2_-aGZFaISeeSijj6i2EA.png" /></figure><p>Number of times a question arises in the mind of a tester “Which automation tool to use: <strong>Protractor </strong>or <strong>Selenium…?</strong> Both perform the same task of automating manual testing. Here, we are going to discuss the relationship between these two i.e. Are these <em>competitors </em>or <em>companions?</em></p><p>Protractor is an end-to-end testing framework for AngularJS applications and works as a solution integrator — combining powerful tools and technologies such as NodeJS, Selenium, web Driver, Jasmine, Cucumber and Mocha.</p><p>In Protractor, we are provided with global <em>“protractor”</em> and <em>“browser”</em> objects, which match the <em>“web driver”</em> and <em>“browser”</em> objects in Selenium respectively. So, if we are already familiar with writing WebDriver code, the most basic way to start writing Protractor code is just to replace web driver with the protractor.</p><p>However, Protractor also provides some syntactic sugar to help us write our tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*GScFwqJdxui5gjfUpviy8A.png" /></figure><p><strong>Using ElementFinders</strong></p><p>In Protractor, we use the <strong>element </strong>function to find and interact with web elements through an ElementFinder object. This extends a WebDriver WebElement by adding chaining and utilities for dealing with lists. See <a href="https://www.protractortest.org/#/locators">locators and actions</a> for details.</p><p><strong>element.all() vs browser.findElements()</strong></p><p>As we know, Protractor is wrapper over WebDriverJS. On top of what is there, it adds a lot of convenient concepts, like ElementFinder or ElementArrayFinder or the browser object.</p><p>Protractor also provides us a way to call the pure WebDriverJS functions and methods directly, for example, it allows us to use of findElement() and findElements() on the browser object.</p><p>In our case, the <em>browser.findElements(by.classname(‘ABCname’) )</em> would return an array of WebElements which is a pure WebdriverJS concept.</p><p><strong>Note</strong>: This is not an ElementArrayFinder instance, we are not at Protractor territory at this point. Now, we are trying to call .all() function on this array of elements and it obviously fails.</p><p>The Protractor way of doing this would be:</p><p><em>var variable =$$(‘ABCname’)</em>;</p><p>v<em>ar variable =$$(‘ABCname’).first()</em>; //To get even get away with a single selector</p><p><strong>Behind the Scenes: ElementFinders versus WebElements</strong></p><p>If we are just curious about the WebElements mentioned above, you may be wondering how they relate to ElementFinders.</p><p>When you call <em>driver.findElement(locator)</em>, WebDriver immediately sends a command over to the browser asking it to locate the element. This isn’t great for creating page objects, because we want to be able to do things in setup (before a page may have been loaded) like</p><p><em>var myButton = ??;</em></p><p>and re-use the variable myButton throughout your test. ElementFinders get around this by simply storing the locator information until an action is called.</p><p>v<em>ar myButton = element(locator);</em></p><p>// No command has been sent to the browser yet.</p><p>The browser will not receive any commands until you call an <em>action</em>.</p><p><em>myButton.click();</em></p><p>// Now two commands are sent to the browser — find the element, and then click it.</p><p>ElementFinders also enable chaining to find sub-elements, such as element(locator1).element(locator2) Process Communication</p><p>Protractor works in conjunction with Selenium to provide an automated test infrastructure that can simulate a user’s interaction with an Angular application running in a browser or mobile device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*Zfm9BBIHoSxC7R-SeHlNWw.png" /></figure><p><strong>Process Communication</strong></p><p>A test using Selenium WebDriver involves three processes — the test script, the server, and the browser. The communication between these processes is shown in the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*O_zPte2hssH9WCd0bB3LNw.png" /></figure><p>The Selenium Server takes care of interpreting commands from the test and forwarding them to one or more browsers. Communication between the server and the browser uses the WebDriver Wire Protocol, a JSON protocol. The command is interpreted by the Browser Driver.</p><p>With Protractor, the test script is run using Node.js. Protractor runs an extra command before performing any action on the browser to ensure that the application being tested has stabilized. For example, let’s look at the following snippet of test code.</p><p><em>element(by.css(‘button.myclass’)).click();</em></p><p>This will result in three commands being sent to the Browser Driver</p><ul><li><strong>/session/:sessionId/execute_async </strong>— First, Protractor tells the browser to run a snippet of JavaScript. This is a custom command which asks Angular to respond when the application is done with all timeouts and asynchronous requests, and ready for the test to resume.</li><li><strong>/session/:sessionId/element </strong>— Then, the command to find the element is sent.</li><li><strong>/session/:sessionId/element/:id/click </strong>— Finally the command to perform a click action is sent.</li></ul><p><strong>Conclusion</strong></p><p>Protractor is a test framework for Angular JS applications that uses Selenium to automate the browser behaviour (Protractor uses JS but still communicates with Selenium using WebDriverJS). It’s true, you can’t still use Selenium Web Server<strong> </strong>API as an alternative to Protractor (with a language of your choice that’s supported) to talk to the Selenium Server</p><p><strong>SELENIUM</strong></p><ul><li>Works great even if you are testing an Angular JS website, you only have to deal with page synchronization issues.</li><li>Selenium supports automation very well and its API is also stable.</li><li>You can write the selenium code in 6 popular programming languages Java, Python, C#, PHP, Ruby, Perl.</li></ul><p><strong>PROTRACTOR</strong></p><ul><li>It is basically an automation testing tool for angular based web pages. But, when you look at its core, it’s a wrapper for Web driver JS. Hence it does not uncover any new vertical in browser automation.</li><li>Yes, it has certain advantages in case of an angular specific locator strategy. It provides more options to work with Angular directives (i.e. angular specific locator strategy e.g. models, bindings, ng-options, ng-repeat).</li><li>It is available only for JavaScript and TypeScript.</li></ul><p>It’s probably personally choice here but if using AngularJS and given they’re the same people that wrote protractor then it’s worth getting familiar with it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4546269d392" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>