I'm running Appium 1.6.1 on Windows 10, and I'm trying to automate Chrome on a real device (in this instance a Samsung Galaxy S7 running Android 7.0). I'm using C# and visual studio. My code looks like the below:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.Android;
namespace MobileBrowserTesting{
[TestClass]
public class UnitTest1{
AppiumDriver<IWebElement> Driver;
[TestMethod]
public void TestMethod1(){
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("deviceName", "hero2lteskt");
caps.SetCapability("udid", "ce11160b3889d43005"); //Give Device ID of your mobile phone
caps.SetCapability("browserName", "Chrome");
//Launch the Android driver
Driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.3:4723/wd/hub"), caps);
Driver.Navigate().GoToUrl("http://www.google.com");
string url = Driver.Url;
bool viewable = Driver.FindElement(By.Id("q")).Displayed;
}
}
}
Chrome launches, however it simply sits at "data;" with a blank screen and doesn't progress to the website. The last step in the Appium view is:
[JSONWP Proxy] Proxying [POST /session] to [POST
http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":
{"chromeOptions":
{"androidPackage": "com.android.chrome","androidDeviceSerial":"ce11160b3889d43005"}}}
[HTTP] <-- POST /wd/hub/session - - ms - -
And visual studio times out with the error message:
Message: Test method MobileBrowserTesting.UnitTest1.TestMethod1 threw
exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.3:4723/wd/hub/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
After a while Appium times out with:
[W3C] Encountered internal error running command: Error: Failed to start
Chromedriver session: An unknown server-side error occurred while processing
the command. (Original error: unknown error: Device ce11160b3889d43005 is
already in use
Appium is launched in admin mode, with "Allow session override" ticked under Advanced.
The chromedriver being used is the latest one (2.39) and the version of chrome on the device is 66.0.3359.158 so it should be compatible.
Any ideas why it seems to hang/not interact with Chrome?
Cheers in advance
Related
I am using Appium automation tool to automate UI testing for mobile app using C#.
Testing environment:
XCode - 13.2.1
iOS - 12.4
Appium 1.22.3
Appium.WebDriver - 4.3.2
When I run tests in iOS simulator 15.2, I can take screenshots using Appium without any errors. But in iOS simulator 12.4, I am getting error when taking screenshot.
Error is falling in the below line:
Screenshot screenshot = driver.GetScreenshot();
Error I got in visual studio:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote
WebDriver server for URL
http://127.0.0.1:4723/wd/hub/session/575ce7df-ffbb-4b2e-957c-e7eca7829b75/screenshot
timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out.
Appium Error Log:
[debug] [W3C (575ce7df)] Calling AppiumDriver.getScreenshot() with
args: ["575ce7df-ffbb-4b2e-957c-e7eca7829b75"]
[debug] [XCUITest] Executing command 'getScreenshot'
[WD Proxy] Error: timeout of 240000ms exceeded
I created a very simple C# project to test Selenium and Chrome Driver, but when I run it, it gets stuck at the very first line, ie. creating ChromeDriver object.
I have set up as following:
.NET Core 3.1 console app (also tried .NET 4.7)
Installed Selenium.WebDriver 3.141.0 and Selenium.WebDriver.ChromeDriver 87.0.4280.8800.
My Chrome version is "Version 87.0.4280.88 (Official Build) (64-bit)". I have double-checked compatibility with Chrome and ChromeDriver.
Code:
using OpenQA.Selenium.Chrome;
namespace MyFirstSelenium
{
class Program
{
static void Main(string[] args)
{
ChromeDriver chrome = new ChromeDriver();
chrome.Navigate().GoToUrl("https://www.google.co.jp/");
}
}
}
visual studio screen
chromedriver.exe is copied to the debug folder as expected, so I assume the problem is neither compatibility nor path.
chromedriver
When I run the code, the result is an empty window with 'data' in the address bar. No error is thrown. I have searched for several hours and found some articles, but most of them are old and none of these answers led to success.
Any help is appreciated. Thank you.
Added chromedriver.exe verbose console output.
#Piotr M.
chromedriver console
logfile
https://drive.google.com/file/d/1ECOS8E55aaTFV63e8P-7n6uRVcf49PRN/view?usp=sharing
New code
Works when I first execute "chromedriver.exe --verbose --log-path=chromedriver.log", but without it, it throws WebDriverException.
OpenQA.Selenium.WebDriverException: 'A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL localhost:9515/session. The status of the exception was UnknownError, and the message was: No connection could be made because the target machine actively refused it. No connection could be made because the target machine actively refused it.'
var chromeOptions = new ChromeOptions();
chromeOptions.BrowserVersion = "87";
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:9515"), chromeOptions);
Possibly a classic case of cyclic redundancy.
chrome is a reserved word, you may have to change the variable name to something else e.g. chromex. So your effective line of code will be:
ChromeDriver chromex = new ChromeDriver();
Additional Consideration
Consider the following aspects aswell:
Instead of using the ChromeDriver class use the IWebDriver interface.
IWebDriver driver = new ChromeDriver();
Instead of the partial url google.co.jp/ you need to pass the complete url through GoToUrl() as follows:
driver.Navigate().GoToUrl(#"https://www.google.co.jp/");
The problem
Hello.
I have a class in C# to verify if my app is installed or not in my device.
When my device has the app installed, everything works fine. However, when my device does not have the app installed, the system gives me this error message:
Message:
Test method MYAPP.Main.RunTest.RunAllTests threw exception:
System.InvalidOperationException: An unknown server-side error
occurred while processing the command. Original error: Could not find
package com.android.MyApp on the device
How to use and declare the IsAppInstalled?
I’m using VS 2017 Community.
Environment
Appium version (or git revision) that exhibits the issue: Appium
Driver v4.0.30319
Last Appium version that did not exhibit the issue (if applicable):
Same
Desktop OS/version used to run Appium: Windows 10 Pro
Node.js version (unless using Appium.app|exe): Node.js v10.1.0
Mobile platform/version under test: Android 8.0
Real device or emulator/simulator: Real device Samsung S9
Appium CLI or Appium.app|exe: Appium Server v1.8.0
Details
My Capabilities:
public class CapDeviceConfig{
public DesiredCapabilities CapDeviceConfigOptions(){
//set the capabilities (https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md)
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("automationName", "Appium"); // Which automation engine to use
cap.SetCapability("platformName", "Android"); // Which mobile OS platform to use
cap.SetCapability("platformVersion", "8.0.0"); // Mobile OS version
cap.SetCapability("deviceName", "starlte"); // The kind of mobile device or emulator to use // S9
cap.SetCapability("udid", "2270048324037ece"); // Unique device identifier of the connected physical device
cap.SetCapability("appPackage", "com.android.MyApp");
cap.SetCapability("appActivity", "md5ab6683a3e3c3f0bd6864e3305b4e45c6.SplashScreenActivity");
cap.SetCapability("noReset", "True"); // Don't reset app state before this session.
cap.SetCapability("printPageSourceOnFindFailure", "True"); // When a find operation fails, print the current page source.
return cap;
}
}
Link to Appium logs
https://gist.github.com/pbmzbr/b0638a0237c7d846de2e94000163c1f6
Code To Reproduce Issue
public class AppInstallVerification{
//Creating instance for Appium driver
AppiumDriver<AndroidElement> driverCheck;
CapDeviceConfig cap = new CapDeviceConfig();
EnrollmentTests enrollmentTests = new EnrollmentTests();
InstallApp install = new InstallApp();
public void IsAppInstalled(){
cap.CapDeviceConfigOptions();
driverCheck = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap.CapDeviceConfigOptions());
if (driverCheck.IsAppInstalled("com.android.MyApp"))
{
Console.WriteLine("App is installed!");
enrollmentTests.CodeApplied();
}
else
{
Console.WriteLine("App is not installed!");
install.InstallingApp();
}
}
}
I'm using Appium and C# in order to run tests on my Galaxy S5.
Everyhting worked perfectly , but last night we have updated the ChromeDriver to 2.25 and suddenly the chrome in my mobile just open the chrome, shows "data:" in the URL and crashes. on the other hand, the chrome in on Windows OS(selenium) works well.
[SetUp]
public void Setup()
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("device", "Android");
capabilities.SetCapability("deviceName", "Galaxy S5");
capabilities.SetCapability("newCommandTimeout", "300");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("platformVersion", "6.0.1");
capabilities.SetCapability("appPackage", "com.android.chrome");
capabilities.SetCapability("appActivity", "org.chromium.chrome.browser.ChromeTabbedActivity");
_driver = new AndroidDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(180));
}
Appium's ERROR:
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: A new session could not be created. (Original error: session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid 'context': {\"auxData\":{\"frameId\":\"31754.1\",\"isDefault\":true},\"id\":1,\"name\":\"\",\"origin\":\"://\"}\n (Session info: chrome=54.0.2840.85)\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64)))","status":33,"value":
updating the Appium's chromedriver manually to the latest one fixed the problem for me.
just downlaod the latest chromedriver vsersion and put it in the following path:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win
I was always able to launch chromedriver server locally but then I tried to do this remotely and since then I am unable to launch it. I reinstalled chrome as well the chrome driver but nothing seems to fix this. Even when I give the path of my driver it won't launch.
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Safari;
using OpenQA.Selenium.Interactions;
namespace TestWebDriver
{
class Program
{
static void Main(string[] args)
{
var driver = new ChromeDriver(#"C:\Users\laurens.putseys\Documents\Visual Studio 2015\Projects\TestWebDriver\packages\Selenium.WebDriver.ChromeDriver.2.21.0.0\driver\");
driver.Url = "http://google.be";
Console.ReadLine();
driver.Quit();
}
}
}
The error I get is the following:
An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll
Additional information: unknown error: chrome failed to start
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64)
It started after I tried this:
System.Environment.SetEnvironmentVariable("webdriver.chrome.driver",#"/path/to/where/you/ve/put/chromedriver.exe"
Now I cannot launch the local either. Launching IE and Firefox local work without any problems. Any ideas? Thanks in advance!
try downloading the driver and give its path to contractor - LINK
driver = new ChromeDriver(DRIVER_PATH);
By the version number (2.21.371459) you can tell that the ChromeDriver executable has been launched by your remote Selenium server. But the ChromeDriver was obviously unable to launch the Chrome browser. Is it installed on the server? Can you launch is manually? Can you watch the remote server on a screen and see what happens? Are there any error message boxes displayed by Chrome?
Maybe uninstalling and re-installing Chrome could help!
I had the same problem. I had the browser set to always run under the administrator.
So I started Visual Studio as an administrator and the problem was solved.