<?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 Harsha Marihal on Medium]]></title>
        <description><![CDATA[Stories by Harsha Marihal on Medium]]></description>
        <link>https://medium.com/@harshamarihal?source=rss-3cb28cd82d83------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WL_jB-EZfok03C7y.</url>
            <title>Stories by Harsha Marihal on Medium</title>
            <link>https://medium.com/@harshamarihal?source=rss-3cb28cd82d83------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:59:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshamarihal/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[Powerful Java 8 Lambdas + Selenium]]></title>
            <link>https://medium.com/@harshamarihal/powerful-java-8-lambdas-selenium-bcf5d751c23b?source=rss-3cb28cd82d83------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf5d751c23b</guid>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[javastreams]]></category>
            <dc:creator><![CDATA[Harsha Marihal]]></dc:creator>
            <pubDate>Fri, 03 May 2019 17:14:04 GMT</pubDate>
            <atom:updated>2020-07-05T02:05:30.471Z</atom:updated>
            <content:encoded><![CDATA[<p>How to use java 8 selenium webdriver</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*f77HtMhGAbdVofWZYZFQRw.png" /></figure><p>We are going to address few of the below challenges /problems we face daily while writing automated scripts using selenium and believe me you gonna love this approach of writing scripts using Java 8 lambdas.</p><p><strong>What is Java 8 Lambdas?</strong></p><p>Basically a Lambda is an anonymous functions with no name and its not bounded to any identifier like below.</p><p>(Parameter)-&gt;expression</p><p><strong><em>Eg: (x)-&gt;fun(x)</em></strong></p><blockquote>Printing all values in Array List can be done in two ways.</blockquote><p>List&lt;String&gt; list=Arrays.asList(”Hello World Example”.split(“ ”));</p><blockquote><strong>Traditional way</strong>-&gt;<em> for(i=0;i≤list.size();i++){System.out.println(list.get(i))} </em>-&gt; In this example concentration is more on loop iteration but our main intention is to just print out the list.</blockquote><blockquote><strong>Lambdas Way</strong>-&gt; Lets see how can we achieve the same implementation using Lambdas -&gt; <em>list.stream().forEach(str-&gt;System.out.println(str))</em></blockquote><p><strong>How can we use Java 8 Lambdas with selenium?</strong></p><p><strong>Will it help us to increase the readability of our code?</strong></p><p><strong>Will it help me to concentrate on implementing functionality rather than focusing on using old fashioned “For” loop ?</strong></p><p>With below example you can see how easily you can achieve/answer above challenges easily.</p><p>Now lets see how can we use Java 8 Lambdas with selenium.</p><ol><li>Lets find all links on a page and filter it and print it on console.</li></ol><pre>@FindBy(xpath=”//a”) <br>private List&lt;WebElement&gt; AllLinks;</pre><pre>List&lt;String&gt; AllLinkText=AllLinks.stream().map(ele -&gt; ele.getText().trim()).collect(Collectors.<em>toList</em>());</pre><pre>List&lt;String&gt; AllLinkTextWithSeleniumText=AllLinks.stream().filter(ele -&gt; ele.getText().contains(&quot;selenium&quot;)).collect(Collectors.<em>toList</em>());</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*ts1_7sPBIQhnYoDtgA0Okw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf5d751c23b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>