<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nishant Kashyap</title>
    <description>The latest articles on DEV Community by Nishant Kashyap (@nishantkayshap).</description>
    <link>https://dev.to/nishantkayshap</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1002387%2F43666196-9cb9-4af0-8d91-d0b031108696.png</url>
      <title>DEV Community: Nishant Kashyap</title>
      <link>https://dev.to/nishantkayshap</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nishantkayshap"/>
    <language>en</language>
    <item>
      <title>Write Your First Automation Script In Just 20 Mins!</title>
      <dc:creator>Nishant Kashyap</dc:creator>
      <pubDate>Thu, 05 Jan 2023 14:39:22 +0000</pubDate>
      <link>https://dev.to/testmuai/write-your-first-automation-script-in-just-20-mins-4dh1</link>
      <guid>https://dev.to/testmuai/write-your-first-automation-script-in-just-20-mins-4dh1</guid>
      <description>&lt;h2&gt;
  
  
  What Is The Need For Automation?
&lt;/h2&gt;

&lt;p&gt;In today’s world, testing can not be efficient without automation. We need automation for avoiding repetitive work, making sure that the time from development to deployment is reduced with good quality. In order to achieve these, we need reliable automation tests and regression suite. Manual test(s) should just support automation for feature/product testing and release not vice-versa.&lt;/p&gt;

&lt;p&gt;We need good, quality automation tests, not just automation tests. We need tests which are reliable, robust, easy to code, debug, scale and can run in parallel on distributed environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/system-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;System Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I write my first UI test?
&lt;/h2&gt;

&lt;p&gt;One love for Selenium! Isn’t it ?&lt;/p&gt;

&lt;p&gt;Since, Selenium is an open source testing tool it serves the need for cost-effective automation testing and the community always support the cost effective tool with required features.&lt;br&gt;
It’s capability to operate on almost every OS and multiple language support i.e. Pearl, PHP,Python, Java, .NET(C#) and Ruby provides the flexibility that every user wants.&lt;br&gt;
The language which is mostly used for building the program is independent of the language that is being used by the web application or website. Which implies that you can develop the test script in any of the mentioned languages that the Selenium supports.&lt;/p&gt;

&lt;p&gt;There are several ways to quickly start automating a GUI flow using selenium. Let’s do it using python.&lt;/p&gt;

&lt;p&gt;**Pre-Req : **We need python and selenium binding to be installed in the machine. If you don’t have already , follow the below steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download and install Python :-&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;MAC: &lt;a href="https://www.python.org/downloads/mac-osx/" rel="noopener noreferrer"&gt;https://www.python.org/downloads/mac-osx/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linux: &lt;a href="https://www.python.org/downloads/source/" rel="noopener noreferrer"&gt;https://www.python.org/downloads/source/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Windows: &lt;a href="https://www.python.org/downloads/windows/" rel="noopener noreferrer"&gt;https://www.python.org/downloads/windows/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Command to check python version using command line :-&lt;br&gt;
python –version&lt;/p&gt;

&lt;p&gt;2- Install selenium libraries for python. &lt;/p&gt;

&lt;p&gt;[&lt;a href="http://selenium-python.readthedocs.io/installation.html" rel="noopener noreferrer"&gt;http://selenium-python.readthedocs.io/installation.html&lt;/a&gt; ]&lt;/p&gt;

&lt;p&gt;command:-&lt;br&gt;
pip install selenium&lt;/p&gt;

&lt;p&gt;3- Install geckodriver&lt;/p&gt;

&lt;p&gt;Since we will use latest version of selenium(3.0) with latest firefox bindings , download geckodriver :-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/mozilla/geckodriver/releases" rel="noopener noreferrer"&gt;https://github.com/mozilla/geckodriver/releases&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OR&lt;br&gt;
Install using command line ( using brew ):-&lt;br&gt;
brew install geckodriver&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/smoke-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Smoke Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples And Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We are all set to write our first test!&lt;/strong&gt;&lt;br&gt;
 Let’s search for an item in myntra.com&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code [ Self Explanatory]:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import Select
    from random import randint

    browser = webdriver.Firefox()
    browser.set_page_load_timeout(30)

    browser.get('https://www.myntra.com/')
    assert "Online Shopping" in browser.title

    search = browser.find_element_by_class_name("desktop-searchBar")  # Find the search box by class
    search.send_keys("watch") #send the value of search field

    submit_button = browser.find_element_by_class_name("desktop-submit")
    submit_button.click()
    #Lets wait for lobby page to load
    delay = 10 # seconds max wait
    myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.CLASS_NAME, "horizontal-filters-title")))
    browser.save_screenshot("loggedIn.png") ## This will be stored in the location/path mentioned or the current directory
    browser.close() # close browser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tips:- Locate selenium elements for python — &lt;a href="http://selenium-python.readthedocs.io/locating-elements.html" rel="noopener noreferrer"&gt;http://selenium-python.readthedocs.io/locating-elements.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aht5EfNek2CqNzeI8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aht5EfNek2CqNzeI8.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This certification is ideal for testing professionals who want to acquire advanced, hands-on knowledge in Selenium automation testing.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Selenium Advanced certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DK21aHjuUE4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/usability-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Usability Testing&lt;/a&gt;: A Comprehensive Guide With Examples And Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>testing</category>
    </item>
    <item>
      <title>Loadable Components In Selenium: Make Your Test Robust For Slow Loading Web Pages</title>
      <dc:creator>Nishant Kashyap</dc:creator>
      <pubDate>Thu, 05 Jan 2023 14:01:34 +0000</pubDate>
      <link>https://dev.to/testmuai/loadable-components-in-selenium-make-your-test-robust-for-slow-loading-web-pages-2n0p</link>
      <guid>https://dev.to/testmuai/loadable-components-in-selenium-make-your-test-robust-for-slow-loading-web-pages-2n0p</guid>
      <description>&lt;p&gt;Being in automation testing for the last 10 years I have faced a lot of problems. Recently I was working on a selenium automation project and in that project everything was going fine until I faced a most common but difficult problem. How to make sure that my selenium automation testing work fine even for slow loading web pages. A quick google and browsing through forums highlighted that this is a problem that testers are facing for many past years. If you too have faced it then yes, this article is there to help you from my personal experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Let’s take a look, at which are the most wanted &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=june_14&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation tools &lt;/a&gt;in 2023 that have climbed the top of the ladder so far?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well, this problem is majorly observed in the case when the web application uses a javascript heavy framework.&lt;/p&gt;

&lt;p&gt;The component that’s gonna help us in page loading is an extended version of PageObject pattern called Loadable component.In the selenium library, Loadable Component class helps the automation test engineers to make sure that the page or its component is loaded successfully. This hack should greatly reduce the efforts that you put in debugging your test cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Appium Tutorial: A Detailed Guide To &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium Automation&lt;/a&gt; Testing&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On a side note, to make your life of testing easy and fuss-free while debugging, you can try the &lt;a href="https://www.lambdatest.com/lt-debug?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LT Debug Chrome extension&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To start with, we would first have to make sure that all the PageObject classes extends the abstract LoadableComponent class and in turn provide implementation for the following two methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;protected abstract void load()&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;protected abstract void isLoaded() throws java.lang.Error&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Code to ensure whether the page or component inside the page is completely loaded in given in isLoaded(). If the page is not completely loaded, java.lang.Error is thrown&lt;/p&gt;

&lt;p&gt;Fallback or mitigation code is given load(), if isLoaded() fails to load the complete page successfully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: A Complete &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;End to End Testing&lt;/a&gt; Tutorial: Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s take an example on how it works :&lt;/p&gt;

&lt;p&gt;Suppose, we have a LoginPage with username, password and submit button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.support.CacheLookup;
    import org.openqa.selenium.support.FindBy;
    import org.openqa.selenium.support.PageFactory;

    public class LoginPage {

    private WebDriver driver;

    @FindBy(id = "login_username")
    private WebElement usernameInputBox;

    @FindBy(id = "login_password")
    private WebElement passwordInputBox;

    @FindBy(id = "login_submit")
    private WebElement loginButton;

    public AdminLoginPageUsingLoadableComponent(WebDriver driver){
    this.driver = driver;
    PageFactory.initElements(driver, this);
    }

    public NextPage login(String loginUsername, String loginPassword){
    usernameInputBox.sendKeys(loginUsername");
    passwordInputBox.sendKeys(loginPassword");
    loginButton.click();

    return PageFactory.initElements(driver, NextPage.class);
    }

    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the above PageObject can be transformed using LoadableCompenent like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   import org.junit.Assert;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.support.CacheLookup;
    import org.openqa.selenium.support.FindBy;
    import org.openqa.selenium.support.PageFactory;
    import org.openqa.selenium.support.ui.LoadableComponent;

    public class LoginPageUsingLoadableComponent extends LoadableCompenent {

    private WebDriver driver;

    @FindBy(id = "login_username")
    private WebElement usernameInputBox;

    @FindBy(id = "login_password")
    private WebElement passwordInputBox;

    @FindBy(id = "login_submit")
    private WebElement loginButton;

    public LoginPageUsingLoadableComponent(WebDriver driver){
    this.driver = driver;
    PageFactory.initElements(driver, this);
    }

    public NextPage login(String loginUsername, String loginPassword){
    usernameInputBox.sendKeys(loginUsername");
    passwordInputBox.sendKeys(loginPassword");
    loginButton.click();

    return PageFactory.initElements(driver, NextPage.class);
    }

    @Override
    protected void load() {
    driver.get("http://www.example.com/login");
    }

    @Override
    protected void isLoaded() throws Error {
    Assert.assertTrue(driver.getCurrentUrl().contains("login"));
    }

    }

    LoginPageUsingLoadableComponent loginPage = new LoginPageUsingLoadableComponent(driver).get();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The get() method from the LoadableComponent class will ensure sure the page or the component is loaded by invoking the isLoaded() method. If the assertion fails there, load() method is called, followed by isLoaded().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: A Complete End to End &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan05_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;(E2E) Testing&lt;/a&gt; Tutorial: Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hope this article helps in stabilizing UI tests !!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqsrzosq4rn5pel1xugam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqsrzosq4rn5pel1xugam.png"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
  </channel>
</rss>
