Know more about Automated Testing in Salesforce
Automated testing is the testing of the software through the specialized tools, which includes performing the following steps: start, initialization, execution, receiving and analysis of the test result.
Selenium is a tool specifically designed to conduct automated testing of web applications in various browsers and within various platforms. It should be noted that any routine actions performed in the browser can be automatically tested using Selenium, not only web applications.
Selenium supports functional and regressive testing.
The main types of locators in Selenium are: ID, ClassName, Name, TagName, LinkText, PartialLinkText, Xpath, CSS Selector, DOM.Xpath is a declarative query language for elements of an XML or XTHML document. It navigates the document based on its logical structure and hierarchy.
- To automate tests on the SF platform, we use the Intelij Idea development environment
- All the tests are related and we use Maven
- pom.xsml is the configuration file of our project
- To write auto tests, we have to use salesforce libraries. Maven automatically downloads them and adds them into our project
- All libraries and their related elements should be enclosed into the Dependencies tag.
- To write auto tests we need junit and selenium webdiver java
- Next, we need to import our changes: click on the link in the lower right corner to Import Changes
- Go to the src folder->test->java, press new package, and define the folder name of our project. We need to make sure that all projects have unique names
In our example, we use Xpath to search elements – we have used it for simplicity although it is not the most reliable way to find the elements. In most cases, it’s better to use unique names as locators.
How to get Xpath for particular element:
- Open the inspector (F12) to find the desired element on the page, click on it;
- After the element is selected in the inspector, right-click on the selected element in the inspector;
- Copy the Xpath element,
- Paste the Xpath into your source where you use driver.findElement (By.xpath (“”)) command.
In our example below, we will log in to the community and create an Idea. For that, we create a Main class containing steps for creating an idea in the Community. We use the AC Enterprise Ideas with Lightning Experience support component v1.28mar19 / 1.28.0
We use the following techniques to post an Idea:
- To find appropriate fields to insert text we use driver.findElement(By.xpath(“”)).sendKeys(“”)
- To find buttons or links to click we, use the driver.findElement(By.xpath(“”)).click()
- To find a drop-down list and select a value from the list, we use
WebElement select = driver.findElement(By.xpath (“”));
List<WebElement>sekect_li = select.findElements(By.tagName (“li”));
- To set the delay in execution, we use the Thread.sleep()
See full source code below
Salesforce Spring 21 Release Notes for Experience Cloud Overview
Salesforce Spring 21 Release comes soon, so the AC team has prepared a quick overview of the main updates about Experience Cloud.
Joining Forces for Success: Introducing Our New Sales Engineer, Director with a Wealth of Experience in Salesforce!
With an impressive background as a Solutions Architect in Salesforce and a passion for delivering excellence for various verticals across the enterprise and commercial markets, Kevin brings a wealth of experience and knowledge to our team. His expertise in Salesforce will undoubtedly play a vital role in driving success for our customers and achieving our business objectives.