DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "9c37fa48");
capabilities.setCapability("browserName", "Android");
capabilities.setCapability("platformVersion", "8");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.xxx.yyy");
capabilities.setCapability("appActivity", "com.xxx.yyy.MainActivity");
capabilities.setCapability("appWaitActivity", "com.xxx.yyy.MainActivity");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
What i see is the code tries to access the app.. After that i get the below exception.
Mar 05, 2019 3:37:23 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Mar 05, 2019 3:37:34 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '405' -> incorrect JSON status mapping for 'unknown error' (500 expected)
FAILED: setUp
org.openqa.selenium.WebDriverException: Method is not implemented
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'M710S-MDT06', ip: '192.168.7.148', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {appActivity: com.wizlearn.tmlearn.MainAc..., appPackage: com.wizlearn.tmlearn, appWaitActivity: com.wizlearn.tmlearn.MainAc..., databaseEnabled: false, desired: {appActivity: com.wizlearn.tmlearn.MainAc..., appPackage: com.wizlearn.tmlearn, appWaitActivity: com.wizlearn.tmlearn.MainAc..., deviceName: 9c37fa48, platformName: android, platformVersion: 8}, deviceManufacturer: samsung, deviceModel: SM-T825Y, deviceName: 9c37fa48, deviceScreenSize: 1536x2048, deviceUDID: 9c37fa48, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: LINUX, platformVersion: 8.0.0, takesScree`enter code here`nshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 8a08634e-3e25-4f30-a114-8b315070fc57
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Appium desktop version: 1.11.0
java version "1.8.0_201"
Selenium 3.141.59
Earlier I used Selenium remote web driver for windows 8.1
For Widnows 10, changed to Anroid Driver .
WebDriver driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Now it works!!
Related
I am using below code to launch the url. But not loading the url.
WebDriverManager.chromedriver().setup();
ChromeOptions option = new ChromeOptions();
option.
addArguments("user-data-dir=C:\\Users\\vkandukur.ctr\\AppData\\Local\\Google\\Chrome\\User Data\\"
);
option.addArguments("--profile-directory=Profile 6");
option.addArguments("--incognito");
WebDriver driver = new ChromeDriver(option);//in selenium4
driver.get("https://peter.sh/experiments/chromium-command-line-switches/");
Getting exceptions:
Starting ChromeDriver 105.0.5195.52 (412c95e518836d8a7d97250d62b29c2ae6a26a85-refs/branch-heads/5195#{#853}) on port 53422
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 400. Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Build info: version: '4.4.0', revision: 'e5c75ed026a'
System info: host: 'INL1TBH6G3', ip: '192.168.43.148', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [user-data-dir=C:\Users\vkan..., --profile-directory=Profile 6, --incognito], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [user-data-dir=C:\Users\vkan..., --profile-directory=Profile 6, --incognito], extensions: []}}}]
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:144)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:157)
at org.openqa.selenium.chromium.ChromiumDriver.(ChromiumDriver.java:101)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:81)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:70)
at com.ironMountain.util.browserConfiguration.ChromeBrowser.main(ChromeBrowser.java:104)
can any one help please
When I use a proxy with ChromeDriver I have Class Cast Exception.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
if (!Context.getProxy().isEmpty()) {
Proxy proxy = new Proxy();
proxy.setHttpProxy(Context.getProxy());
capabilities.setCapability(CapabilityType.PROXY, proxy);
}
System.setProperty(Driver.CHROME.getDriverName(), pathWebdriver);
return new ChromeDriver(capabilities);
if Context.getProxy().isEmpty() = true, I Web driver is ok, but if I Set a proxy I have this error:
org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{ensureCleanSession=true, proxy=Proxy(manual, http=renn.proxy.corp.xxxx:8080), loggingPrefs=org.openqa.selenium.logging.LoggingPreferences#5df041, browserName=chrome, version=, platform=ANY, unexpectedAlertBehaviour=accept}]
at org.openqa.selenium.remote.BeanToJsonConverter.convert(BeanToJsonConverter.java:69)
...
...
Caused by: org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{ensureCleanSession=true, proxy=Proxy(manual, http=renn.proxy.corp.xxxx:8080), loggingPrefs=org.openqa.selenium.logging.LoggingPreferences#5df041, browserName=chrome, version=, platform=ANY, unexpectedAlertBehaviour=accept}]
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'ITEM-72885', ip: '192.168.84.9', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_66'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:88)
at org.openqa.selenium.remote.BeanToJsonConverter.convert(BeanToJsonConverter.java:66)
... 84 more
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:223)
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:143)
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:189)
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:86)
... 85 more
Problem resolved when I upgraded the driver version.
I am facing the problem while executing the code to maximize the window.
Below is the error message:
unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=58.0.3029.110)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.03 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'SDN-117', ip: '172.10.189.52', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed), userDataDir=C:\Users\TANUJA~1\AppData\Local\Temp\scoped_dir9140_12941}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=58.0.3029.110, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 12757c3f618b72bfaffb8713a175d458
Kindly help me to sort out the problem.
Here is the Answer to your Question:
To maximize Google Chrome browser window it is recommended to use ChromeOptions class instead of driver.manage().window().maximize();. Here is the sample code for your reference:
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver driver = new ChromeDriver(options);
Let me know if this Answers your Question.
My protractor scripts are highly stable on chrome browser but the same scripts throws below mentioned for 20% of the test cases.
Failed: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 100 milliseconds
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'LAPTOP-RNQ2JQBE', ip: '192.168.89.115', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=true, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:41897/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
Session ID: f32d0eb8-65d9-4161-9535-da5cde8b9a6c
Failed: Error while waiting for Protractor to sync with the page:
"Unable to get property '$$testability' of undefined or null
reference"
I have the following configuration :
Webdriver version : 3.3.0
Chrome version : 56
Chromedriver version : 2.24
OS Version : Windows 10
The exception I am facing is given below. I am quite new to selenium so not sure what could be the possible reason. I tried executing the same code with severla versions of chromedriver but with no luck
Starting ChromeDriver 2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf) on port 45496
Only local connections are allowed.
Mar 13, 2017 8:27:43 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.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: 'unknown', revision: 'b526bd5', time: '2017-03-07 11:11:07 -0800'
System info: host: 'DESKTOP-CU1N4JE', ip: '192.168.1.4', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: chrome failed to start
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 10.0.14393 x86_64), platform=ANY}]
Session ID: 0f4877e9d55cf1682ea6b45d0196319a
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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:638)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:835)
at pkg_1302_02.Cl_1303_02.main(Cl_1303_02.java:19)
You are using an older version of chrome driver. Using latest chrome drive will solve the issue. Download latest chrome driver from Link to download Chrome driver