id | title | hide_title | sidebar_label | description | keywords | url | site_name | slug | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error-messages |
Common Error Messages That May Happen During Test Execution |
true |
Error Messages During Test Execution |
Here is a list of various error messages that may happen during test execution. |
|
LambdaTest |
error-messages/ |
import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "LambdaTest", "item": "https://www.lambdatest.com" },{ "@type": "ListItem", "position": 2, "name": "Support", "item": "https://www.lambdatest.com/support/docs/" },{ "@type": "ListItem", "position": 3, "name": "Error Messages During Test Execution", "item": "https://www.lambdatest.com/support/docs/error-messages/" }] }) }} ></script>Below is a list of various error messages that may happen during test execution.
This happens due to Username or Access Key passed by you is missing or invalid.
- Go to LambdaTest Automation Dashboard.
- Click on the key icon at the right top of the dashboard.
- Copy username and access key.
The test was terminated because it exceeded the maximum duration allowed. (default is 1800 seconds).
This might be caused by several issues:
- Your test is too long. A single test case may be composed of multiple tests.
- Test stucks in the endless loop, where test keeps sending commands.
- Consider breaking up your test into smaller, atomic tests.
- You can use the maxDuration desired capability option to indicate how long you want to wait for your test to complete.
- In your test check for endless loops.
When a test is placed under a queue but gets cancelled before execution.
This might occur due to various reasons:
- The connection between the local machine of the user and LambdaTest cloud server is aborted.
- High latency may also lead your test script to test cancellation.
- User cancels the test manually after placing it in queue.
Your test runner started a new test on LambdaTest, but then closed the connection before we could make a new test session available.
This might occur due to several things:
- Client timeout with browser tests. Please make sure to set the connection timeout in your test runner/framework high enough, as old browsers take a while to start up. It would be best to wait for at least a couple minutes.
- You might be running too many tests at once. If you're exceeding the total number of concurrent test limit, we still queue the tests as per your plan. If this queueing takes too long, your test runner might disconnect before the test started.
- Increase the connection timeout setting in your test runner/framework. For example, for WebdriverIO, you can set connectionRetryTimeout: 210000.
- Make sure you're not exceeding the total allowed concurrent test limit as per LambdaTest Automation plan you're subscribed to.
There are times when you may encounter Lambda Error stating the below message.
Lambda Error: Uh Oh! Looks like our Grid failed to recognize your test input.
There could be numerous reasons behind this error messages. The most common ones are listed below:
- Infrastructure Unavailability: In case of too many incoming requests, sometimes our cloud server may fail to allocate a VM as per your request.
- Incorrect Data Type for Desired Capabilities: If you send a string input for an integer data type capability then you may encounter Lambda Error.
- Excessive web-traffic spikes may also lead to Lambda Error.
The Element Click command could not be completed because the element receiving the events is obscuring the element that was requested clicked.
- It usually occurs when the target element that you want to click is overlaid by some other element in the web page.
- There are multiple ways to solve the given issue - check StackOverFlow for more information
A command could not be completed because the element is not pointer- or keyboard interactable.
-
Element has not properly rendered
-
Element has rendered but it is not in the visible part of the screen
For 1. -> Use implicit /explicit wait:
-
Implicit wait :
{`driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);`} -
Explicit wait :
{`WebDriverWait wait=new WebDriverWait(driver, 20); element1 = wait.until(ExpectedConditions.elementToBeClickable(By.className("fa-stack-1x")));`}
For 2. -> Solution is just to scroll till the element. Based on the version of Selenium it can be handled in different ways. For more information, refer this link.
Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate.
- SSL works through a combination of programs and encryption/decryption routine that exist on the web server computer and web server browser.
- When a secure connection is not established between the server and client due to the certificate, following SSL certificate error will be manifested.
- Suppose you provide some https request in the browser and get a prompt such as “This connection is untrusted” or the “The site’s security certificate is not trusted” (which varies as per the browser being used). Then such an error is subject to SSL certificate error.
We can essentially adjust our script such that the SSL exception is handled by itself, using Selenium Webdriver.
- For understanding and handling SSL errors - check this site for more information
The arguments passed to a command are either invalid or malformed. Example:
It is for example not possible to set a window size to a negative value:
Output:
- The invalid argument error is a WebDriver error that occurs when the arguments passed to a command are either invalid or malformed.
- Invalid argument errors can be likened to TypeErrors in JavaScript, in that they can occur for a great many APIs when the input value is not of the expected type or malformed in some way.
- Check the values in your input and ensure they are actually valid.
An illegal attempt was made to set a cookie under a different domain than the current page.
- The invalid cookie domain error is a WebDriver error that occurs when an illegal attempt was made to set a cookie under a different domain than that of the current document. In WebDriver it is not permissible to set cookies for other domains than the domain of the current browsing context's document's domain. Example: If the current domain were to be 'example.com', it would not be possible to add a cookie for the domain 'example.org':
Output:
A command could not be completed because the element is in an invalid state, e.g. attempting to clear an element that isn't both editable and resettable.
- When we try to perform some operation which is not applicable then it will throw InvalidElementStateException.
- Let’s assume if the textbox is disabled and if you try to perform type operation then it will throw an exception.
- If radio button,checkbox or any other web element is disabled and if you try to perform click event then it will throw an exception.
- If any element supports only click events and if you try to perform type events then again it will throw an exception
- Ensure performing the required operation based on element state.
- If it is clickable element then perform click and if it supports type event then perform sendkeys.
- If the element is disabled then enable it first and then perform operations.
For more, refer this link (learn-automation.com) .
Argument was an invalid selector.
-
The invalid selector error is a WebDriver error that occurs when an element retrieval command is used with an unknown web element selector strategy.
-
The available selector strategies are CSS, link text, partial link text, tag name, and XPath. Any other selector strategy is rejected with this error.
- Do check the punctuations such as @, ', and [].
- Make sure that there is only one field name with that path; else, use the contains() method
Occurs if the given session id is not in the list of active sessions, meaning the session either does not exist or that it's not active.
- As of 04/2021, sync mode will not be supported anymore starting from Node.js v16 due to changes in Chromium.
- It is therefore advisable to use async to solve this error
- The WebdriverIO site has an official guideline for the same - "How to enable/disable sync mode". Please take a look on this: WebdriverIO
A new session could not be created.
- Incompatibility between version of the binaries being used
- Can be primarily solved by ensuring Chrome version being used and the JDK, driver versions are compatible. Refer this link - stackoverflow
The Javascript error is a WebDriver error that occurs when a script the supplied by the user fails to execute.
Example:
Output:
- The underlying cause of the execution error is often supplied in the error message, along with a stacktrace provided by the JavaScript engine in the browser.
- Check for invalid declarations and definitions in your code
Argument was an invalid selector.
-
The invalid selector error is a WebDriver error that occurs when an element retrieval command is used with an unknown web element selector strategy.
-
The available selector strategies are CSS, link text, partial link text, tag name, and XPath. Any other selector strategy is rejected with this error.
- Do check the punctuations such as @, ', and [].
- Make sure that there is only one field name with that path; else, use the contains() method
The target for mouse interaction is not in the browser’s viewport and cannot be brought into that viewport.
Example:
- Selenium enables replication for exact human behavior, so if code failure indicates element is not visible, then it is actually a case of element not being visible.
- For a concise explanation regarding this error - refer here.
An attempt was made to operate on a modal dialog when one was not open.
Refer these links for one of the possible explanations:
- no-alert-is-present-no-modal-dialog-found-webdriver-unable-to-catch-js-error
- selenium-webdriver-unexpected-modal-dialog-alert
No cookie matching the given path name was found amongst the associated cookies of the current browsing context's active document.
Example:
- Creating a cookie before navigation to the site
- For a concise explanation regarding this error - refer here.
An element could not be located on the page using the given search parameters.
Example:
Majorly in two cases
-
When using
webdriver.find_element_by_*("expression") //example : my_element = driver.find_element_by_xpath("xpath_expression")
-
When using
element.find_element_by_*("expression")//example : my_element = element.find_element_by_*("expression")
There are different possibilities for this error to occur. Check the link below for more information.
- A detailed explanation regarding this error - refer here.
A command to switch to a frame could not be satisfied because the frame could not be found.
Example:
- As per the HTML to switch to the desired frame you need to use WebDriverwait for the frame to be available and switch to it
Implement suitable edits to either css selector or XPATH
CSS Selector
:WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[id^='layui-layer-iframe'][src^='fangyuan']")))
XPATH
:WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[starts-with(@id,'layui-layer-iframe') and starts-with(@src,'fangyuan')]")))
A command to switch to a window could not be satisfied because the window could not be found.
Example:
There are multiple approaches to this problem:
- In export configuration, to delete everything at the end, you have to set
killinstances
totrue
- Check all the required configurations for the corresponding web browser driver (esp. for InternetExplorerDriver)
- Enabling protected mode for all zones often might do the trick.
For more, refer Stack Overflow
The element does not have a shadow root.
For GET
request of Element Shadow Root - with URI template /session/{session id}/element/{element id}/shadow
, if shadow root
is null then error is returned with error code no such shadow root
.
For explanation regarding locator strategy, refer this link
A command failed because the referenced element is no longer attached to the DOM. Example:
-
The stale element reference error is a WebDriver error that occurs because the referenced web element is no longer 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.
Some common solutions include:
-
Refreshing the webpage -
driver.navigate().refresh(); driver.findElement(By.xpath("xpath here")).click();
-
Using 'try-catch' block within 'for loop' -
- Using ExpectedConditions.refreshed
Wait for the element until its available. Use ExpectedConditions.refreshed to avoid StaleElementReferenceException and retrieve the element again. This method updates the element by redrawing it and we can access the referenced element.
wait.until(ExpectedConditions.refreshed(ExpectedConditions.stalenessOf("table")));
- Using POM (lazy initialization) In POM, we use initElements() method which loads the element but it won’t initialize elements. initElements() takes latest address
For a detailed explanation regarding the approach to solve this error -
Indicates that a command that should have executed properly cannot be supported for some reason.
Example:
(for java)
An UnsupportedOperationException is thrown when a requested operation cannot be performed because it is not supported for that particular class. One of the most common causes for this exception is using the asList()
method of the java.util.Arrays
class. Since this method returns a fixed-size unmodifiable List
, the add()
or remove()
methods are unsupported. Trying to add or remove elements from such a List
will throw the UnsupportedOperationException
exception.
Other cases where this exception can occur include:
Using wrappers between collections and primitive types.
Trying to remove elements using an Iterator
.
Trying to add, remove or set elements using ListIterator
.
- The
UnsupportedOperationException
can be resolved by using a mutable collection, such asArrayList
, which can be modified. An unmodifiable collection or data structure should not be attempted to be modified.
Refer this explanation from Rollbar for more info - Link
The requested command matched a known URL but did not match any method for that URL.
Example:
The unknown method error is a WebDriver error that occurs when the driver does not recognize the HTTP request method used for the endpoint.
- WebDriver provides a largely REST-ish API and not all endpoints in this API has
GET
,POST
, andDELETE
methods. This error occurs when you try to call an endpoint with an HTTP request method it does not support.
Refer this example - Unknown Method error
The unknown element error is a WebDriver error that occurs when an unspecified error occurs in the driver whilst processing a command.
An unknown error will usually be specific to a particular driver, so it's a good idea to read the error message, if any, for an indication of what happened.
The unknown command error is a WebDriver error that occurs when the driver does not recognize the command/HTTP endpoint.
Example: The /session/{session id}/foo endpoint does not exist, and will return an unknown command error with a 404 Not Found HTTP status code
An operation did not complete before its timeout expired
The script timeout error is a WebDriver error that occurs when a script the user has provided did not complete before the session's script timeout duration expired.
The script timeout duration is a configurable capability, which means you can change how long it will take before the driver interrupts an injected script. The driver will by default wait 30 seconds before interrupting the script and returning with a script timeout error, but this can be both extended, limited, and be set to indefinite.
If the session script timeout duration is set to indefinite by using a null
value, you are at risk of putting the session into a non-recoverable state. Be aware that this should be used with caution.
Example:
Output:
{ScriptTimeoutException: Timed out after 35000 ms
}
- A workaround would be to use capabilities to extend the session's default script timeout.
A command to set a cookie's value could not be satisfied.
org.openqa.selenium.UnableToSetCookieException: Unable to set cookie (WARNING: The server did not provide any stacktrace information)
Example:
Creation of a cookie before navigating to the site.
If you are trying to create a cookie on the domain www.example.com
, then you would want to navigate to some page on that domain, create the cookie, and then start your test.
The best way to do this is to navigate to some page you know will not exist on the domain, e.g. www.example.com/this404page
, then create the cookie. It should load a lot faster since it's an error page and shouldn't contain much content. After creating the cookie on the 404 page, start the test.
A screen capture was made impossible.
Possible explanations - (For Appium)
A command could not be executed because the remote end is not aware of it.
org.openqa.selenium.UnhandledAlertException: unexpected alert open
Example:
This is happening because of the default behaviour of the driver when it encounters an alert. The default behaviour was set to "ACCEPT", thus the alert was closed automatically, and the switchTo().alert() couldn't find it explicitly.
The solution is to modify the default behaviour of the driver to ("IGNORE"), so that it doesn't close the alert but just ignores it.
Thereafter you could use try-catch to catch the errors if any.