Posts

Stale element reference error in Selenium Scripting and how to solve it?

 Stale element reference error and solution What is Stale element reference error❓❓ The  stale element reference error occurs when the referred element not attached to the DOM. Every DOM element is represented in WebDriver by a unique identifying reference, known as a web element. The web element reference is a UUID used to execute commands targeting specific elements, such as getting an element’s tag name and retrieving a property off an element. When an element is no longer attached to the DOM, i.e. it has been removed from the document or the document has changed, it is said to be stale. Staleness occurs for example when you have a web element reference and the document it was retrieved from navigates. The Error Trace is: org.openqa.selenium.StaleElementReferenceException: stale element  reference: element is not attached to the page document Solution - 1: Wait till the element is properly rendered and clickable, use below code: WebDriverWait wait =...

Implicit vs Explicit vs Fluent And Sleep in Selenium

  Why Do We Need Selenium Waits when there is Sleep in java ? Most of the time a common problem faced by almost all automation tester is " ElementNotVisibleException ".   I saw the people scratching their head because of this!. Visually, when seeing the UI execution of script, we face a common question that, "we can see the element but why our script cant find this!!"❓ here is the catch! Usually, when navigation happens from one page to other/ on dynamically loading or hiding elements, there will be a delay of fractions. Hence, some time our eye won't catch that, though script may encounter of fail to find element. Hence, to resolve this we should apply wait! Types of Selenium Waits For Page Load Thread.Sleep() method Implicit Wait Explicit Wait Fluent Wait https://play.google.com/store/apps/details?id=com.shikshan.app Thread.Sleep()  For Automation Testing with Selenium Sleep is a static method that belongs to the thread class in java. This method can...

Selenium Page Object Generator Chrome Extension

Image
Selenium Page Object Generator Chrome Extension This chrome extension helps in creating the page object class for Selenium WebDriver with locators for all available elements and methods to access them. It uses a template to generate the class which can be customized from the settings page of the extension. Selenium Page Object Generator is a good tool to improve the workflow. It will generate Page Object Model on active Chrome tab with a single click, provided that all the options and template are configured. The generated Page Object Model can be saved to pre-configured Chrome download folder. It currently supports 3 different targets: Java, C#, and Robot Framework. You can search for this extension in Chrome Browser. PageObjectGenerator Extension Once we add this extension to Chrome, we can easily generate Page Objects for the applications which we need to automate. Usage: Launch Chrome browser and the extension can be found at the top rig...

Software Engineering Ethics and Professional Practices Principle 2

Image

Software Engineering Ethics and Professional Practices Principle 1

Image

Run Selenium Tests In Headless Google Chrome

Run Selenium Tests In Headless Google Chrome Selenium is one of the most popular, open source and efficient browser automation tools available today. With Selenium Web Driver, it automates several (browser) actions, such as opening a webpage, clicking a link, checking the URL, and so on. But there are cases when you may need to run automation tests in ‘headless’ mode, i.e., when no browser is being displayed. In these cases, you can execute Selenium tests in headless browsers. This is useful when testing in cloud Dockers/linux What Is A Headless Browser? A headless browser is a simulation module/browser which do not have user interface. These programs operate like any other browser, but do not display any UI. When Selenium tests are run, it executes in the background Benefits Of Headless Browser Testing: 1. Improves speed and performance Since this type of testing does not actually open a browser, the system saves the processing power that would otherwise be used...

How to inspect disappearing element in a browser:

Image
How to inspect disappearing element in a browser: In selenium scripting we should  use right techniques for identifying the web elements. In few cases when there is disappearing items like KendoUI, we should use smart ways/techniques for identifying the elements rather than spending lot of time behind analyzing the javascript/reactjs codes. Technique/Tools  1.  For finding the elements and xpaths, we can use the tools like  ChroPath, CSS Selector or any other Chrome plugins 2. Once we identified the proper xpath or elements with id/css, we can confirm its presence with similar tools like Xpath Helper Wizard Then, we can use it in our page factory logic So, challenge here is, few elements like KendoUI date pickers closes soon after changing the focus,  To find elements of these kind we can use 2 techniques: 1. In Chrome,  Open devTools (F12) Select the "Sources" tab While the element you want is displayed, press F8...