Skip to content

Introducing the new algoQA MCP, built to handle all of the work with your LLM.

Learn more
Back to list

Test Automation

How to Choose Locators for Automation Testing?

How to Choose Locators for Automation Testing? A good locator provides stability for test automation with low maintenance requirements.

  • Vadeesh BudramaneAuthor

4 min read

How to Choose Locators for Automation Testing?

A good locator provides stability for test automation with low maintenance requirements.

But how to choose reliable locators for automation testing?

Let us find out in the following sections.

Criteria for Selecting Good Locators for Test Automation

  • A locator should be small and stays unaffected by modifications in parents.
  • A locator needs to match the desired element. There is no use of locators if it matches other elements during the software testing.
  • A single locator should match unique and specific elements.
  • Multiple locators should match with an equal number of elements but no others.
  • Do not trust changeable information for choosing locators. You need to determine the difference between reliable and non-reliable information carefully.
  • It is crucial because it will help to conduct low-maintenance and stable automation testing.
  • Choose a locator that can pull through its property changes or upgrades.
  • Don’t use elements that depend upon self-generated values like id=tooltip
  • Use locators such as ID, CSS, Xpath, etc
  • Locators should be independent of HTML structure for stability.

How do form locators use attributes such as IDs, Class Names etc

Locators’ formation through the following attributes and path.

Location

Description

Syntax in Java

ID

Recognise the web element applying the ID attribute

Driver.findElement (By.id(“idvalue”)

Class Name

Apply the Class attribute to recognise the web element

Driver.findElement (By.className (“classValue”)

CSS Selector

CSS used to create style rules in a web page is leveraged to locate the desired web element

Driver.findElement (By.cssSelector (“cssValue”)

Tag Name

Tag name to locate the web element

Driver.findElement (By.tagName (“htmltag”)

XPath

Apply XPath to locate the required web element

Driver.findElement (By.xpath(“xpathvalue”)

Partial Link Text

Use a part of the text in hyperlinks to locate the desired web element

Driver.findElement (By.partialLinkText (“PartialTextofLink”)

Link Text

Use the texts in hyperlinks to recognise the web element

Driver.findElement (By.linkText (“textoflink”)

Name

Recognise the web element with the Name attribute

Driver.findElement (By.name (“namevalue”)

How to write dynamic locators vs static locators?

  • Locators are vital components of writing a successful software testing script. Some of these elements are static, and some of them are dynamic. There are different methods to manage both categories of locators.
  • Static locators remain unchanged. Dynamic elements rely on changing aspects.
  • Static objects remain stable. It is easy to manage and choose a preferable selector like XPath. Though XPath is commonly applied, other selectors follow a similar method.
  • Dynamic locators are tricky as they function according to changing properties. It needs to be more stable.
  • You can use algoQA for locator finding to conduct faster & efficient software testing.

How to implement polling methods?

Polling methods in software testing improves the efficiency of application to manage multiple requests. It is highly recommendable for applications that require a long time to process one request.

If one request takes lots of time, there will be a backlog of requests, and the system will not accept new requests.

Example

A client can manage 100 requests at a time. The server takes some minutes to process one request. This situation could cause an inability to accept new customer requests, as there are no free threads.

There should be an asynchronous client instead of a synchronous one to avoid blocking. The polling method is the solution for the asynchronous technique.

How does the polling method work?

  • The client sends an HTTP request to the server
  • The server receives the request and responds with processing of the request still in progress
  • The client conducts a poll method for the server to check if the request has been processed or not
  • The client receives the response if the request has been processed.
  • If processing is still pending, the poll happens again

Benefits of Choosing algoQA

  • algoQA has a scraper that does the job without manually having to inspect one by one every UI element.
  • It is an artificial intelligence-powered end-to-end automation testing platform.
  • algoQA from AlgoShack facilitates testing beyond UI automation.
  • The automation platform provides a single platform for UI-based functional test automation, load test automation, and API test automation.
  • It is a technology-agnostic platform. It supports multi-lingual scripting, seamless working across ALMs, and multiple reporting formats.
  • You can use algoQA for Web Applications, Mobile Applications, Hybrid Applications, Desktop Applications, Robotic Process Automation, and Embedded Software.
  • Leverages AI and ML for accurate test automation results
  • Auto coding and faster machine-generated scripts
  • algoQA facilitates environment configuration with pre-set browsers, operating systems, and mobile settings.
  • Better methods to manage flaky automation tests
  • Update test automation scripts in seconds
  • You can automatically capture and store locators, in elements repositories.
  • Provides thousands of test cases and executable scripts
  • The enhanced overall productivity of automation tests and minimises go-to-market time.
  • SaaS-based rapid automation with the best return on investment

Learn more about locators and working with algoQA at https://algoshack.com/algoqa/. Contact us for a demo now.

Everything you need to know about algoShack.

See all blogs

FAQs

Frequently Asked Questions

Everything you need to know about algoShack.

Product

Tool updates

algoQA is updated as product capabilities evolve, supported technologies change, and customer feedback identifies new automation needs. Updates may include new integrations, improved test generation, expanded platform support, usability improvements, and fixes.

Do you produce UFT scripts?

algoQA is designed to generate and manage automation assets in the formats supported by the configured framework and project. UFT script generation depends on the required workflow, framework configuration, and engagement scope. Confirm the target UFT version and project requirements during onboarding.

Framework support and capabilities that can be achieved using the tool

algoQA supports framework-based automation and can be configured to match the technologies, test patterns, and delivery practices used by your project. The achievable capabilities depend on the application under test, the selected framework, integrations, and the level of customization required.

Version control repos support

algoQA can work with version-controlled repositories so teams can manage automation assets alongside application code and other project artifacts. Repository workflows, branching conventions, review processes, and access permissions depend on your project configuration and selected source-control platform.

Modular scripts?

algoQA supports modular automation design. Teams can separate reusable actions, components, test data, and business flows instead of maintaining each test as an isolated script. Modular design reduces duplication and makes changes easier to apply across related tests.

Object repository maintenance

algoQA helps organize and maintain the application objects and locators used by automation. Centralizing object information reduces the number of scripts that need direct updates when an application changes. The exact maintenance workflow depends on the application technology and automation framework.

Security

The system shall provide a secure, computer-generated, time-stamped audit trail to record the date and time of the operator entries and actions that create, modify, or delete electronic records.

Yes, algoQA can provide an audit trail.

The audit trail shall ensure that the original electronic record, along with the date and time stamp, is not lost and that the new record along with the date and time of the modification is recorded with a reason for change.

Yes, algoQA maintains logs along with their corresponding timestamps.

The system shall ensure data is retained and readily available for users to generate records in human-readable and/or electronic form.

Yes, algoQA includes a backup and restore feature.

The system shall protect records to preserve their content and meaning, and enable their accurate retrieval throughout the records retention period.

Yes, data is stored throughout the retention period.

The system shall allow only Authorized Persons to certify the release of batches. The person releasing or certifying batches shall be clearly identified and recorded using an electronic signature (Security and Access Management Requirements).
The system shall ensure that passwords are not displayed during entry.

Let's build something worth trusting.

Book a demo and see the agents run against a slice of your own application, or talk to us about joining the team. Zero setup cost to begin.