As per the error elementisnotvisible seems you are pretty close. Moving forward as you are trying to invoke Click()
on the element, so instead of ExpectedConditions as ElementIsVisible()
you need to use ElementToBeClickable()
as follows:
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id='pdp-size-select']"))).Click();
With out any reference to SeleniumExtras
and WaitHelpers
the line of code will be:
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id='pdp-size-select']"))).Click();
Note: As you mentioned you are using Chrome v67.x ensure that you are using ChromeDriver v2.40 (but not ChromeDriver v2.4)
Update
Debugging further it seems the Locator Strategy you have adapted, identifies exactly two (2) elements within the HTML DOM. So you need to construct a unique locator to identify and click the desired element as follows:
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a[@data-track-action='Product-Page']//following::select[@id='pdp-size-select']"))).Click();
Note: The desired element is a select
element and if you desire to interect with the <select>
element as per best practices you need to use the SelectElement Class from OpenQA.Selenium.Support.UI Namespace.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…