How to test webappication in chrome on windows 10?


#1

I am trying to automate tests for a web application running in chrome on Windows 10 using Appium.
I have code like below that works perfectly fine uses chromedriver. I want to move this to appium based approach.

RemoteWebDriver driver = new ChromeDriver(@"C:\Users\Administrator\Downloads\chromedriver_win32");
            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));

driver.Url = "https://www.bing.com/";
RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(x => x.Title.Contains("webdriver"));

I searched internet and find a lot of code to test webapplications on chrome on android emulators on windows devices. I did not find any sample that runs chrome browser directly on windows 10.
Based on what i understood, i tried adopting the code by making changes to desired capabilities like below.

DesiredCapabilities caps = DesiredCapabilities.Chrome();
caps.SetCapability(CapabilityType.BrowserName, "chrome");
caps.SetCapability(CapabilityType.Version, "60");
caps.SetCapability(CapabilityType.Platform, "Windows 10");
caps.SetCapability("platformName", "Windows");
//caps.SetCapability("app", @"C:\Users\Administrator\Downloads\chromedriver_win32\Chromedriver.exe");
caps.SetCapability("app", @"Chrome");
caps.SetCapability("deviceName", "WindowsPC");

driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4725/wd/hub"), caps, TimeSpan.FromSeconds(60));
driver.Url = "https://www.bing.com/";
((IWebDriver)driver).Navigate().GoToUrl("https://www.bing.com/");
RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);

Thread.Sleep(5000);
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(x => x.Title.Contains("webdriver"));

This however doesn’t work.
I think the problem is I am not able to figure out how to set desired capabilities so that appium service running on http://127.0.0.1:4725/wd/hub is able to launch chromedriver and run tests.

Can someone please help point out mistake with the above code?
Appreciate your help.


#2

Have you thought about using Selenium for testing on your Windows machine? Appium is really meant for MobileDevices (although it does have a component for Windows application testing).

I’m a big proponent for using the right tool for the job. You may be able to get this to work, but it would be much simpler to go the Selenium route. Selenium is a more mature code base than Appium, and the syntax will be very comparable. Here are a couple of Windows specific tutorials on using Selenium on Windows:

https://www.guru99.com/installing-selenium-webdriver.html

And here is the Selenium Google Group, which they use as their discussion board. Good Luck!

https://groups.google.com/forum/#!forum/selenium-users


#3

Thanks for responding along with relevant material wreed,
I was evaluating appium to see if it becomes one stop shop for all environments.