The status of this library is beta.
It is a library for operating ChromiumWebBrowser with the interface of Selenium. Supports WinForms & WPF.
Install Selenium.CefSharp.Driver from NuGet
PM> Install-Package Selenium.CefSharp.Driver
https://www.nuget.org/packages/Selenium.CefSharp.Driver/
Chrome driver is able to manipulate apps that are configured only with CefSharp, but it can't manipulate apps that used CefSharp for only part of it. This problem will be solved by using CefSharpDriver.
This library is a layer on top of Friendly, so you must learn that first. But it is very easy to learn.
https://github.com/Codeer-Software/Friendly
https://github.com/Codeer-Software/Selenium.CefSharp.Driver/tree/master/Project/Sample
Sample App.
Code.
usingSystem.Diagnostics;usingSystem.IO;usingCodeer.Friendly;usingCodeer.Friendly.Dynamic;usingCodeer.Friendly.Windows;usingCodeer.Friendly.Windows.Grasp;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium;usingOpenQA.Selenium.Interactions;usingOpenQA.Selenium.Support.UI;usingRM.Friendly.WPFStandardControls;usingSelenium.CefSharp.Driver;namespaceSampleTest{[TestClass]publicclassUnitTest{WindowsAppFriend_app;CefSharpDriver_driver;[TestInitialize]publicvoidTestInitialize(){//start process.varprocess=Process.Start(ProcessPath);//attach by friendly._app=newWindowsAppFriend(process);//show next dialog.varmainWindow=_app.WaitForIdentifyFromTypeFullName("SampleApp.MainWindow");varbutton=newWPFButtonBase(mainWindow.Dynamic()._buttonNextDialog);button.EmulateClick(newAsync());//get next dialog.varnextDialog=_app.WaitForIdentifyFromTypeFullName("SampleApp.NextDialog");//create driver._driver=newCefSharpDriver(nextDialog.Dynamic()._browser);}[TestCleanup]publicvoidTestCleanup()=>Process.GetProcessById(_app.ProcessId).Kill();[TestMethod]publicvoidTestMethod(){//set url._driver.Url=HtmlPath;//find element by id.varbutton=_driver.FindElement(By.Id("testButtonClick"));//click.button.Click();//find element by name.vartextBox=_driver.FindElement(By.Name("nameInput"));//sendkeys.textBox.SendKeys("abc");//find element by tag.varselect=_driver.FindElement(By.TagName("select"));//selenium support.newSelectElement(select).SelectByText("Orange");//find element by xpath.varbuttonAlt=_driver.FindElement(By.XPath("//*[@id=\"form\"]/table/tbody/tr[7]/td/input[2]"));//actions.newActions(_driver).KeyDown(Keys.Alt).Click(buttonAlt).Build().Perform();//execute javascript.vardefaultValue=(string)_driver.ExecuteScript("return arguments[0].defaultValue;",textBox);}staticstringTestDir{get{vardir=typeof(UnitTest).Assembly.Location;for(inti=0;i<4;i++)dir=Path.GetDirectoryName(dir);returndir;}}staticstringProcessPath=>Path.Combine(TestDir,@"SampleApp\bin\x86\Debug\SampleApp.exe");staticstringHtmlPath=>Path.Combine(TestDir,"Controls.html");}}I'm not using WebDriver. The function is realized by the combination of the following processes.
Call the API of another process.
Various processing is realized by JavaScript.
A low level key mouse emulation. However, I am adjusting the timing.
Thank you!
https://github.com/SeleniumHQ/selenium