What are the advanced tips in Selenium scripting?

Nowadays, application development is much faster. So there is a need to test those applications fast within a short period of time. Here ‘Automation’ is testing plays an important role. It reduces the manual testing time/effort and produces more appropriate testing output. There are lots of automation testing tools available in the market.

Selenium is one of the most popular and widely used automation testing suites. It is open source and appropriate for web based application testing across different platforms and browsers. Selenium was first introduced in 2004.

Selenium is not just a single automation testing tool. But it actually comprises of a bunch of software, supporting different testing needs of the application. Let us have a look at its four basic components.

  • Selenium IDE: This is a Firefox plugin used to create simple automated tests. It has a recording feature which allows recording user actions and saving it as a script. This script is a reusable component.
  • Selenium Remote Control (RC): This is a tool which allows users to control the browser by using programming languages
  • Selenium Webdriver: It allows scripts to communicate directly with the browsers.
  • Selenium Grid: It allows running testes in parallel on various remote machines.

Now let us have a look at some advanced tips used in Selenium scripting

Efficient use ‘waits’: The most common solution for ‘waiting’ (for some processing to be completed) is to use Thread.Sleep (). Men det er ikke bekreftet at behandlingen skal være avsluttet innen den angitte tiden nevnt i Thread.Sleep (). Så løsningen er å bruke WebDriverWait klasse. Den bruker en mekanisme til basseng søket etter en bestemt tidsperiode før ventebetingelsen er oppfylt. Dette er også kjent som "eksplisitt’ vente.

Hold miljøparametre i en tekst / xml fil: Det er alltid anbefalt å holde alle dine miljøparametre i en sentral tekst / xml fil. Og deretter analysere fil for å få riktig informasjon. Det hjelper de tester for å være uavhengig av en bestemt parameter / verdi.

Javascript kode: Det er to måter for utførelse av Java-skript, ene er ved hjelp ExecuteScript () og den andre er ExecuteAsyncScript (). Bruk den første, når testen logikken har noen avhengighet av henrettelsen resultat. Den andre kan brukes når det ikke er slik avhengighet.

Utfør Drag & Slippe: Bruk alltid WebDriver handlings- Builder API for 'Drag & Slippe’ operations. De to fremgangsmåter er 'DragAndDrop’ og 'DragAndDropToOffset'. Mer lavt nivå "Drag & Slippe’ kan utføres, men disse teknikkene er sjelden brukt.

Windows og iframe veksling: Bruk alltid driver.SwitchTo ().Ramme () og driver.SwitchTo ().Vindu () metoder for å bytte mellom vinduer og iframes.

Passerer keyboard input: Det er to måter å passere teksten til selen inngangselementene. Den ene er ved hjelp av Javascript-metoder som ExecuteScript () / ExecuteAsyncScript (). Den andre måten er å bruke SendKeys () metode.

Lukke nettlesere: Bruk WebDriver er følgende APIer for å lukke nettleseren etter at testen er fullført.

  • Slutte (): This is used to close all the browsers.
  • Close (): This is used to close the current browser
  • Dispose (): This will internally call Quit () method and has the same effect

Selenium as a testing suite is evolving continuously and it will have more new features in near future. Hope the above tips will help you running Selenium testing more efficiently.

Tagged on:
============================================= ============================================== Buy best TechAlpine Books on Amazon
============================================== ---------------------------------------------------------------- electrician ct chestnutelectric
error

Enjoy this blog? Please spread the word :)

Follow by Email
LinkedIn
LinkedIn
Share