Useful Tips & Commands when recording Test Cases

Updated 4 months ago by Estela García

Copado Selenium Testing does not control some actions which have to be performed by your provider, such as BrowserStack, Sauce Lab, etc. Some commands are recommendable in order to avoid possible provider’s latencies or failures.

  • Use “open” command and add a direct URL to access one tab or specific page instead of recording all the clicks to get to that page. It is shorter, network latencies free and more efficient. We don’t want to test salesforce is working properly but Copado is working as expected.
  • Use the "Generate test case from last page" feature in Copado Recorder to create a complete script from the page you are recording. 
  • Note: be aware of the fact that some pop-ups and modal windows do not have a different URL than the previous page and you may be recording an incorrect page when using the “Generate test case from last page” feature.
  • Use datasets within your tests instead of creating several test cases.
  • Copy & Paste commands from one test case to another instead of recording the whole path again.
  • Use command CopadoContext command to switchToClassic and switchToLightning context to make sure the test does not fail because someone changed the context. This command also allows to find a New button or the Details tab in a page.
  • Some locators sometimes are difficult to detect. In case the element is not detected by the test, select another locator from the drop down menu in Copado Recorder. In different environments, elements have different identifiers, so sometimes, selenium does not find them easily.
  • Use “Manage Test Runs manually” checkbox in order to have a customized tests group where each suite or test is run in a specific environment.
  • Use copadoSetRetries and waitForElementPresent commands to avoid a failing test because of network or provider latencies.
  • Use v10 new commands: gotoIfError / gotoIf / gotoLabel / … to avoid known or possible errors which you don’t want to make your tests fail.
  • Some Alerts are not being properly detected by Selenium. Use verifyConfirmation, verifyAlert, etc. commands to detect them.
  • You can get a screen capture at any moment during a test run by just adding the following command in the recorder window: captureEntirePageScreenshot.
  • If you are testing a managed app before and after packaging, you can use the {!NS} variable to insert the namespace, configured in the Environment record.
  • If you need to execute a command with a blank value (to set a field as empty, for example), you can use the {!BLANK} variable for its value.
  • Useful date and datetime variables are: {!TODAY}, {!TODAY-1} (yesterday), {!NOW}, etc.

How did we do?