ArgumentException Class
ArgumentException is thrown when one of the arguments provided to a method is not valid. Details:
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class ArgumentException : SystemException
FindElement Method
FindElement()
method takes only single argument and is defined as follows:
IWebElement FindElement(
By by
)
Parameters:
by
Type: OpenQA.Selenium.By
The locating mechanism to use.
Return Value:
Type: IWebElement
The first matching IWebElement on the current context.
This usecase
In your code trials you have attempted to send 2 arguments to FindElement()
method as follows:
if (driver.FindElement(By.Id("ember20"), timeout).Displayed)
Hence you see system.argumentexception
An ideal way would had been to send only the By
parameter as an argument as follows:
if (driver.FindElement(By.Id("ember20")).Displayed)
However, this line of code would also have raised NoSuchElementException as the Id
attribute ember20
is dynamically generated through Ember.js and the numeric part would be dynamic.
Solution
A canonical approach would have been to lookout for the visibility of the element inducing WebDriverWait for the ExpectedConditions as ElementIsVisible()
using either of the the following Locator Strategies:
CssSelector
:
IWebElement element = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("CssSelector_identifying_the_element_uniquely")));
XPath
:
IWebElement element = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("XPath_identifying_the_element_uniquely")));
Additional Consideration
Ensure that:
- ChromeDriver is updated to current ChromeDriver v79.0 level.
- Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Reference
You can find a relevant discussion in: