How to resolve org.openqa.selenium.WebDriverException?
This is happening because when selenium is trying to click ,the desired element is not clickable.
You have to make sure that the Xpath provided by you is absolutely right.If you are sure about the Xpath then try the following
replace
WebElement sendIssue = driver.findElement(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button"));
sendIssue.click();
with
WebElement sendIssue =(WebElement)new WebDriverWait(DRIVER,10).until(ExpectedConditions.elementToBeClickable(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button")));
sendIssue.click();
If that doesn't work ,You will get an Timeout exception, In that case try incaresing the timeout amount from 10 to 20.
If it still doesn't work please post a screenshot of the HTML.
You need to write something in the issue title and description to make the issue clickable are you sure you are not making that mistake of clicking the button without writing anything in those places I am adding screenshot for your convenience.
org.openqa.selenium.WebDriverException: [Exception... Component not initialized error using GeckoDriver and Tor browser with Selenium Java
This error message...
Exception in thread "main" org.openqa.selenium.WebDriverException: [Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/modal.js :: get window :: line 143" data: no]
...implies that that the Marionette threw an error while attempting to interacting with the desired element.
It seems the get window
was invoked too early even before the DOM Tree was completely rendered. To be more specific addEventListener
was invoked even before the Browser Client (i.e. the Web Browser) have attained 'document.readyState'
equal to "complete"
. Generally once this condition is fulfilled Selenium performs the next line of code.
Solution
A quick solution will be to before you try to interact with any of the element on a fresh loaded webpage instead of ExpectedConditions as presenceOfElementLocated
you need to induce WebDriverWait for the elementToBeClickable()
and you can use either of the following Locator Strategies:
Using id:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.id("form-postbox-new"))).sendKeys("testmail123");
Using cssSelector:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("#form-postbox-new"))).sendKeys("testmail123");
Using xpath:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='form-postbox-new']"))).sendKeys("testmail123");
Additional Considerations
Ensure that:
- Upgrade JDK to recent levels JDK 8u251.
Note: Selenium have issues with Java 9, Java 11 and Java 13.
- Upgrade Selenium to current levels Version 3.141.59.
- Upgrade GeckoDriver to GeckoDriver v0.26.0 level.
- Firefox is upgraded to current _Firefox v77.0.1 _ levels.
- Ensure that the version of the binaries you are using are compatable.
You can find a detailed discussion in Which Firefox browser versions supported for given Geckodriver version?
- GeckoDriver is present in the desired location.
- GeckoDriver is having executable permission for non-root users.
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
Test
as a non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
- “Component not initialized” nsresult: “0xc1f30001 (NS_ERROR_NOT_INITIALIZED)” error with Selenium GeckoDriver and Mozilla
- WebDriverException: Message: Exception… “Failure” nsresult: “0x80004005 (NS_ERROR_FAILURE)” while saving a large html file using Selenium Python
Outro
Occur the 'NS_ERROR_NOT_INITIALIZED' when switching the window to bottom dock.
Exception in thread main org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status error while clicking using Selenium
As @ArundeepChohan mentioned in his comments ideally to click on any clickable element instead of visibilityOfElementLocated() you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategy:
WebDriverWait waits = new WebDriverWait(driver, Duration.ofSeconds(10));
waits.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[class='CartTotal-secureCheckout'] span")));
driver.findElement(By.cssSelector("button[class='CartTotal-secureCheckout'] span")).click();
In a single line:
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[class='CartTotal-secureCheckout'] span"))).click();
Exception in thread main org.openqa.selenium.WebDriverException: unknown error: unexpected command response using Selenium Java
To click on the element No thanks instead of visibilityOfElementLocated() you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategy:
Using id:
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.id("birtviewer"))).click();
Using cssSelector:
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button#wzrk-cancel"))).click();
Using xpath:
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id='wzrk-cancel']"))).click();
selenium.common.exceptions.WebDriverException: Message: target frame detached
Try to check that:
- Selenium is upgraded to the latest available version
- ChromeDriver and Chrome Browser are updated to the latest available version
- Or, if you use Firefox, check that GeckoDriver and Firefox Browser are updated to the latest available version
How to fix selenium web driver 'exception error' with python
There is an iframe
which blocking to access the element.You need to switched to iframe
first.
Try following code.
WebDriverWait(driver, 15).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, 'iframe.top')))
username = WebDriverWait(driver, 3).until(EC.element_to_be_clickable((By.ID, 'username')))
username.click()
username.send_keys('usernameForUSer')
Browser Snapshot:
Python Selenium: Handling Webdriver exception
This error message...
WebDriverException Traceback (most recent call last)
.
(Session info: chrome=79.0.3945.88)
(Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.15.2 x86_64)
...implies that the ChromeDriver was unable to communicate with the Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using chromedriver=41.0
- Release Notes of chromedriver=2.41 clearly mentions the following :
Supports Chrome v67-69
- You are using chrome=79.0
- Release Notes of ChromeDriver v79.0 clearly mentions the following :
Supports Chrome version 79
So there is a clear mismatch between ChromeDriver v2.41 and the Chrome Browser v79.0
Solution
Ensure that:
- Selenium is upgraded to current levels Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v79.0.3945.36 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.
- (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
- (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
- If your base Web Client version is too old, then uninstall it and released version of Web Client.
- Take a System Reboot.
- Execute your
@Test
as non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
Related Topics
How to Create a Form in Rails Without Having to Use Form_For and a Model Instance
Can Activerecord Connect to Postgresql Remotely and Protect the Db Password
Set Tag Attribute and Add Plain Text Content to the Tag Using Nokogiri Builder (Ruby)
C1 or C2 Coverage Tool for Ruby
Single Occurrence Event with Ice_Cube Gem Using Start_Time and End_Time
Making a Soap Request by Using Xml in Rails
Rails First_Or_Create Activerecord Method
How to Mock Aws Sdk (V2) with Rspec
Using Will_Paginate Without :Total_Entries to Improve a Lengthy Query
Automatic Logging of Datamapper Queries
Run a Ruby Library from the Command-Line
What's the Cleanest Way to Override Activerecord's Find for Both Models and Collections
Why Don't Ruby Methods Have Lexical Scope
How to Fix Libv8 Error from Gemfile on Mavericks
Actiondispatch::Http::Uploadedfile.Content_Type Not Being Initialized in Rspec Test