Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I executed selenium code but an error is appearing

Tags:

java

selenium

Using this script but an error message appears.

WebElement elecounty = (driver.findElement(By.xpath("//div[@class='select_county']//span[text()='select'] ")));
//Thread.sleep(5000);
elecounty.click();Thread.sleep(5000);
elecounty.sendKeys("Baker");

Error message:

element not interactable
  (Session info: chrome=75.0.3770.142)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'NAV-L186', ip: '192.168.0.186', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_212'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 75.0.3770.142, chrome: {chromedriverVersion: 75.0.3770.90 (a6dcaf7e3ec6f..., userDataDir: ...}, goog:chromeOptions: {debuggerAddress: localhost:58326}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: d287681e8c023df5adc766bffc9d5b15
like image 884
zafar ahmad Avatar asked Mar 07 '26 00:03

zafar ahmad


1 Answers

ElementNotInteractableException is thrown to indicate that although an element is present with in the HTML DOM, it is not in a state that can be interacted with.

You should use WebDriverWait with ExpectedCondition.elementToBeClickable:

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement elecounty = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='select_county']//span[text()='select']")));
elecounty.click();
like image 79
Moshe Slavin Avatar answered Mar 09 '26 12:03

Moshe Slavin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!