Selenium getting error - java

This is my selenium test script.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Adminlogin {
public static void main(String[] args) {
//File file = new File("C:/Selenium/IEDriverServer_x64_2.53.1/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", "C:/Selenium/IEDriverServer_x64_2.53.1/IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
//driver.close(); //Closes the browser
}
}
I am getting this error,
Started InternetExplorerDriver server (64-bit)
2.53.1.0
Listening on port 35197
Only local connections are allowed
Oct 07, 2016 9:54:51 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Oct 07, 2016 9:54:52 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Oct 07, 2016 9:54:52 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'
System info: host: 'user-PC', ip: '192.168.2.113', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:228)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:180)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:144)
at Sanitytests.Adminlogin.main(Adminlogin.java:13)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}], required capabilities = null
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'
System info: host: 'user-PC', ip: '192.168.2.113', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_31'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:597)

Well, I had a simmilar error, due to SessionNotCreatedException, caused by DesiredCapabilities discrepancy.
On further research, I went back to https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver. In the "Required Configuration" section was my solution:
"Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog."
So, I went to Tools -> Internet Options -> Advanced Settings -> Security section.
Unchecked "Enable enhanced protected mode". Bingo!
I recommend you go through the "Required Configuration" section in the github link above. There might be other settings you need to apply.

I realized that IE browser capabilities had to be changed to support selenium. like zoom, protected mode, etc ...
try changing IE settings and it should work.

Related

Unable to create driver instance for Edge driver

Code is working fine for chrome but for Edge I'm facing issue
I have set below properties in application.properties file
driver.name=edgeDriver
webdriver.edge.driver = drivers/msedgedriver.exe
I have also downloaded edgedriver.exe as per current version of my edge browser
Edge Version : Version 89.0.774.63
When I am trying to execute the test I am seeing below messages in console log
Unable to get class
com.qmetry.qaf.automation.step.client.TestStepExporter from jar
/C:/Users/piyush/.m2/repository/com/qmetry/qaf/3.0.0/qaf-3.0.0.jar
[QAFTestBase] - Initializing
Driver...browser_str:edgeDriver,base_url:https://qmetry.github.io/qaf/,sel_server:localhost,port:4444
[UiDriverFactory] - Driver: edgeDriver Mar 26, 2021 3:25:36 PM
org.openqa.selenium.remote.DesiredCapabilities edge INFO: Using new EdgeOptions() is preferred to DesiredCapabilities.edge()
Unable to create driver instance in 1st attempt with retry timeout of
30 seconds. You can check/set value of 'driver.init.retry.timeout'
appropriately to set retry timeout on driver initialization
failure.Unable to Create Driver Instance for edge:
java.lang.NoSuchMethodException:
org.openqa.selenium.edge.EdgeDriver.(java.net.URL,
org.openqa.selenium.Capabilities)
Build info: version: '3.141.59', revision: 'e82be7d358', time:
'2018-11-14T08:17:03'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version:
'10.0', java.version: '11.0.10'
Driver info: driver.version: unknown
Referred to how to use edgeDriver with qaf
it seems the property webdriver.edge.driver should be appended with "system" prefix. That means:
system.webdriver.edge.driver = drivers/msedgedriver.exe
After this, Page launched successfully

Unable to Create New session with Microsoft Edge with desired capabilities

I am trying to create a Java test using Edge Webdriver and Edge version 86 (available to download).
I am using EdgeOptions as suggested on many threads here
System.setProperty("webdriver.edge.driver", "C:\\edgedriver\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
WebDriver driver = new EdgeDriver(edgeOptions);
driver.get("https://bing.com");
I get the below error when i execute the script
Error:
Starting MSEdgeDriver 86.0.622.43 (aecc56815110f44c6552813fdd27a416872192c8) on port 35032
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800'
System info: host: 'XXXXXXXXXX', ip: 'XXXXXXX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: EdgeDriver

Selenium Webdriver Problem cannot open google chrome

chrome driver 77
chrome version 77
Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865#{#442}) on port 38929
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created
from disconnected: unable to send message to renderer
(Session info: chrome=77.0.3865.90)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'DESKTOP-JCFLT7B', ip: '192.168.1.113', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.2'
Driver info: driver.version: ChromeDriver
remote stacktrace: Backtrace:
Versions of driver and of Chrome should match.
In Chrome, disable autoupdates. Otherwise after launching Chrome will be updated and can became incompatible with Java driver.

Having java.nio.file.FileSystemException issue while running my code using Selenium 3.4.0

While running the below code, I am getting the below error. This code is working fine with Selenium 2.53.1
Browser details:
Chrome - Version 59.0.3071.115 (64-bit)
Chrome driver - 2.30
Below code works perfectly with normal Java project. Facing issue with Maven Project only.
public class TestSel {
public static void main(String[] args) {
System.setProperty("WebDriver.chrome.driver", "chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://gmail.com");
driver.manage().window().maximize();
System.out.println("Testing Complete");
}
}
Error logs:
Starting ChromeDriver 2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41) on port 21042
Only local connections are allowed.
Jul 03, 2017 1:57:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: java.nio.file.FileSystemException: C:\Users\vijender\AppData\Local\Temp\new-session2428533575725549690.json: The process cannot access the file because it is being used by another process.
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'LC-VIJENDERC', ip: '192.168.6.83', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at rough.TestSel.main(TestSel.java:10)
Caused by: java.nio.file.FileSystemException: C:\Users\vijender\AppData\Local\Temp\new-session2428533575725549690.json: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
at java.nio.file.Files.deleteIfExists(Files.java:1165)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:168)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 8 more
The issue was my system specific. Resolved by window reset.

error: cannot find Chrome binary - Selenium OSX java Eclipse

I'm trying to launch Chrome using Selenium. I was able to apply this same code (with minor changes) to Firefox, but for some reason Chrome is not working.
It says it can't find the Chrome binary, but I have the chromedriver correctly linked to its file source.
Feedback anyone?
Code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class scociatest1 {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "/Users/theone/Downloads/chromedriver-2");
// Create a new instance of the Chrome driver
WebDriver driver = new ChromeDriver();
//Launch the Scocia Demo Website
driver.get("https://apps.scotiabank.com/LEAP_Prototype/desktop/html/Chile_index.html#");
// Print a Log In message to the screen
System.out.println("Successfully opened the website");
}
}
Error Details:
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 33806
Only local connections are allowed.
Nov 24, 2016 4:14:02 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov 24, 2016 4:14:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'Thes-MacBook-Air.local', ip: '10.0.9.17', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64), platform=ANY}]
Session ID: ede6a5a0ba4b5c7b2734be4418af439e
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
at com.scocia.test.scociatest1.main(scociatest1.java:16)
You seem to be running your test from a Windows machine. Then your chromedriver should be an exe file --> "/Users/theone/Downloads/chromedriver-2.exe". After that, if it still doesn't work, you can check with an absolute path.

Categories