Web 元素代码:
<div class="form_field form_field--has_error sc-fBuWsC bNcPjv"
<input id="temporaryEmail" autocomplete="false" name="temporaryEmail" class="sc-hzDkRC gHYxbL" value=""/>
<label for="temporaryEmail" class="sc-jhAzac heNtmJ">
Email Address
</label>
</div>
我的驱动程序代码
public IWebElement emailfield => Driver.FindElement(By.XPath("//input[@id='temporaryEmail']"));
如果我只使用:emailfield.SendKeys(signUpCredentials.emailAddress);
我收到错误 未处理的异常:OpenQA.Selenium.ElementNotInteractableException: 'element not interactable'
如果我使用:
((IJavaScriptExecutor)Driver).ExecuteScript("$('document.querySelector(#temporaryEmail'))", emailfield);
emailfield.SendKeys(signUpCredentials.emailAddress);
我收到错误 未处理的异常:OpenQA.Selenium.WebDriverException: 'javascript error: Unexpected token ')'
(Session info: chrome=77.0.3865.120)'
尝试通过javascript执行器使用以下命令
((IJavaScriptExecutor)Driver).ExecuteScript("document.querySelector('#temporaryEmail')", emailfield);