├── .gitignore
├── CHANGELOG.txt
├── Examples
├── AutoIt
│ └── ListLinksToExcel.au3
├── Excel
│ ├── CloudBrowserStack.xlsm
│ ├── CloudSauceLab.xlsm
│ ├── Examples.xlsm
│ ├── ExamplesNoRegistration.xlsm
│ └── ExamplesPageObject.xlsm
├── JavaScript
│ └── SimpleGoogleSearch(IE).js
└── VBScript
│ ├── BasicAuthentication(Firefox).vbs
│ ├── CaptureToPdf(Firefox).vbs
│ ├── CaptureToPdf(PhantomJs).vbs
│ ├── CompareRendering(Firefox).vbs
│ ├── CompareRendering(PhantomJS).vbs
│ ├── CustomProfileWith(Chrome).vbs
│ ├── CustomProfileWith(Firefox).vbs
│ ├── DownloadFile(Chrome).vbs
│ ├── DownloadFile(Firefox).vbs
│ ├── GmailSignIn(Firefox).vbs
│ ├── ListLinks(Firefox).vbs
│ ├── ListLinksToExcel(Firefox).vbs
│ ├── PageObject.vbs
│ ├── Remoting(Firefox).vbs
│ └── SimpleGoogleSearch(Firefox).vbs
├── FirefoxAddons
├── build-implicit-wait.py
├── build-vb-format.py
├── implicit-wait
│ ├── chrome.manifest
│ ├── chrome
│ │ ├── content
│ │ │ ├── extension-loader.xul
│ │ │ ├── implicit-wait-ext.js
│ │ │ ├── implicit-wait-ide.js
│ │ │ ├── implicit-wait-ide.xml
│ │ │ └── view
│ │ │ │ ├── implicitwait.png
│ │ │ │ ├── selenium-ide-overlay-iw.css
│ │ │ │ └── selenium-ide-overlay-iw.xul
│ │ └── locale
│ │ │ └── en-US
│ │ │ └── implicit-wait.dtd
│ ├── install.rdf
│ ├── update.rdf
│ └── user-extensions.js
├── install.rdf
└── vb-format
│ ├── chrome.manifest
│ ├── chrome
│ └── content
│ │ └── formats
│ │ ├── format-loader.xul
│ │ ├── vba-rc.js
│ │ ├── vba-wd.js
│ │ ├── vbs-rc.js
│ │ └── vbs-wd.js
│ └── install.rdf
├── LICENSE.txt
├── README.md
├── Scripts
├── QuickTest.vbs
├── RunCleaner.vbs
├── StartChrome.vbs
├── StartChromeDebug.vbs
├── StartEdge.vbs
├── StartFirefox.vbs
├── StartInternetExplorer.vbs
├── StartOpera.vbs
└── StartPhantomJS.vbs
├── Selenium.Tests
├── Internals
│ ├── BaseBrowsers.cs
│ ├── BaseExcel.cs
│ ├── COM.cs
│ ├── IgnoreFixtureAttribute.cs
│ ├── TypeExt.cs
│ └── WebServer.cs
├── Pages
│ ├── eiffel-tower.jpg
│ ├── element.html
│ ├── elements.html
│ ├── findby.html
│ ├── frame1.html
│ ├── frame2.html
│ ├── frame3.html
│ ├── input.html
│ ├── links.html
│ ├── select.html
│ ├── table.html
│ ├── win1.html
│ ├── win2.html
│ └── win3.html
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Selenium.Tests.csproj
├── TS_Actions.cs
├── TS_Alert.cs
├── TS_Assert.cs
├── TS_By.cs
├── TS_Capture.cs
├── TS_Element.cs
├── TS_Excel.cs
├── TS_ExecuteScript.cs
├── TS_Frame.cs
├── TS_Keyboard.cs
├── TS_Manage.cs
├── TS_Mouse.cs
├── TS_PDF.cs
├── TS_Scraping.cs
├── TS_SearchContext.cs
├── TS_Select.cs
├── TS_Serialiser.cs
├── TS_Verify.cs
├── TS_Window.cs
├── TS_Windows.cs
├── TS_zip.cs
└── tests.nunit
├── Selenium
├── Application.cs
├── Assert.cs
├── ComInterfaces
│ ├── _Actions.cs
│ ├── _Alerts.cs
│ ├── _Application.cs
│ ├── _Assert.cs
│ ├── _By.cs
│ ├── _Cookie.cs
│ ├── _Cookies.cs
│ ├── _Dictionary.cs
│ ├── _DictionaryItem.cs
│ ├── _IME.cs
│ ├── _Image.cs
│ ├── _Keyboard.cs
│ ├── _Keys.cs
│ ├── _List.cs
│ ├── _Logs.cs
│ ├── _Manage.cs
│ ├── _Mouse.cs
│ ├── _PdfFile.cs
│ ├── _Point.cs
│ ├── _Proxy.cs
│ ├── _SelectElement.cs
│ ├── _Size.cs
│ ├── _Storage.cs
│ ├── _Table.cs
│ ├── _TableElement.cs
│ ├── _TableRow.cs
│ ├── _Timeouts.cs
│ ├── _TouchActions.cs
│ ├── _TouchScreen.cs
│ ├── _Utils.cs
│ ├── _Verify.cs
│ ├── _Waiter.cs
│ ├── _WebDriver.cs
│ ├── _WebElement.cs
│ ├── _WebElements.cs
│ └── _Window.cs
├── Common
│ ├── Actions.cs
│ ├── Alert.cs
│ ├── By.cs
│ ├── CacheState.cs
│ ├── Capabilities.cs
│ ├── Cookie.cs
│ ├── Cookies.cs
│ ├── IME.cs
│ ├── Image.cs
│ ├── Keyboard.cs
│ ├── Keys.cs
│ ├── Logs.cs
│ ├── Manage.cs
│ ├── Mouse.cs
│ ├── MouseButton.cs
│ ├── Proxy.cs
│ ├── SearchContext.cs
│ ├── SelectElement.cs
│ ├── Storage.cs
│ ├── Strategy.cs
│ ├── TableElement.cs
│ ├── Timeouts.cs
│ ├── TouchActions.cs
│ ├── TouchScreen.cs
│ ├── WebElement.cs
│ ├── WebElements.cs
│ └── Window.cs
├── Core
│ ├── DeserializeException.cs
│ ├── DriverExtension.cs
│ ├── DriverService.cs
│ ├── FirefoxPrefs.js
│ ├── FirefoxService.cs
│ ├── FrameContext.cs
│ ├── IDriverService.cs
│ ├── JavascriptContext.cs
│ ├── RemoteServer.cs
│ ├── RemoteSession.cs
│ ├── RequestMethod.cs
│ ├── SysWaiter.cs
│ └── WindowContext.cs
├── Drivers
│ ├── ChromeDriver.cs
│ ├── EdgeDriver.cs
│ ├── FirefoxDriver.cs
│ ├── IEDriver.cs
│ ├── OperaDriver.cs
│ └── PhantomJSDriver.cs
├── Errors
│ ├── ArgumentErrors.cs
│ ├── DictionaryErrors.cs
│ ├── FileNotFoundError.cs
│ ├── ImageErrors.cs
│ ├── InvalidOperationError.cs
│ ├── KeyboardInterruptError.cs
│ ├── NotImplementedError.cs
│ ├── PdfErrors.cs
│ └── WebRequestErrors.cs
├── Internal
│ ├── AssemblyExt.cs
│ ├── AssemblyURLAttribute.cs
│ ├── COMDisposable.cs
│ ├── COMExt.cs
│ ├── COMRunningObject.cs
│ ├── ClipboardExt.cs
│ ├── Crc32.cs
│ ├── EndPointExt.cs
│ ├── ExcelExt.cs
│ ├── ExceptionDialog.Designer.cs
│ ├── ExceptionDialog.cs
│ ├── FolderCache.cs
│ ├── HotKeyGlobal.cs
│ ├── HotKeyGlobalLL.cs
│ ├── IOExt.cs
│ ├── ImgExt.cs
│ ├── IniFile.cs
│ ├── ObjExt.cs
│ ├── ProcessExt.cs
│ ├── StringExt.cs
│ ├── ThreadExt.cs
│ └── UnhandledException.cs
├── Interop
│ ├── Excel
│ │ ├── Excel.cs
│ │ ├── ICells.cs
│ │ ├── IExcel.cs
│ │ ├── IListObject.cs
│ │ ├── IRange.cs
│ │ ├── IWorkbook.cs
│ │ ├── IWorkbooks.cs
│ │ ├── IWorksheet.cs
│ │ └── IWorksheets.cs
│ └── IStdPicture.cs
├── NamespaceDoc.cs
├── Pdf
│ ├── PdfFile.cs
│ ├── PdfFont.cs
│ ├── PdfFonts.cs
│ ├── PdfImage.cs
│ ├── PdfOutlines.cs
│ ├── PdfPage.cs
│ ├── PdfPages.cs
│ ├── PdfWriter.cs
│ └── PdfXRefs.cs
├── Properties
│ └── AssemblyInfo.cs
├── Selenium.csproj
├── Selenium.shfbproj
├── SeleniumError.cs
├── SeleniumException.cs
├── Serializer
│ ├── IJsonBinary.cs
│ ├── IJsonObject.cs
│ ├── JSON.cs
│ └── JsonException.cs
├── Struct
│ ├── Dictionary.cs
│ ├── DictionaryItem.cs
│ ├── List.cs
│ ├── Point.cs
│ ├── Size.cs
│ ├── Table.cs
│ └── TableRow.cs
├── Utils.cs
├── Verify.cs
├── Waiter.cs
├── WebDriver.cs
├── Zip
│ ├── ZipException.cs
│ └── ZipFile.cs
└── key.snk
├── SeleniumBasic.sln
├── SeleniumBasicSetup.iss
├── SeleniumBasicSetup.pas
├── Templates
├── Selenium(advanced).vbs
├── Selenium.au3
├── Selenium.vbs
└── Selenium.xltm
├── Utils
└── CleanRegistry.bat
├── VbsConsole
├── ConsoleArgument.cs
├── ConsoleArguments.cs
├── ExitException.cs
├── IWscript.cs
├── Interop
│ ├── IMSScriptContol.cs
│ ├── IMSScriptControl_Events.cs
│ ├── IMSScriptError.cs
│ ├── IMSScriptModule.cs
│ ├── IMSScriptModules.cs
│ ├── IMSScriptProcedure.cs
│ ├── IMSScriptProcedures.cs
│ ├── MSScriptControlConstants.cs
│ ├── MSScriptControl_EventProvider.cs
│ ├── MSScriptControl_EventSink.cs
│ └── ScriptControlStates.cs
├── Logger.cs
├── MultiScriptRunner.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── RunnerVbNet.cs
├── Script.cs
├── ScriptControl.cs
├── ScriptDebugger.cs
├── ScriptError.cs
├── ScriptModule.cs
├── ScriptProcedure.cs
├── ScriptProcedures.cs
├── ScriptResult.cs
├── ScriptRunner.cs
├── ScriptSuccees.cs
├── TraceLine.cs
├── Utils.cs
├── VbsConsole.csproj
├── WScript.cs
└── WithParams.cs
├── build-setup.py
├── clean-folders.py
├── clean-registry.py
├── gen-registration.ipy
├── rebuild_exel_files.py
├── smoke-tests.py
└── update-references.py
/.gitignore:
--------------------------------------------------------------------------------
1 | References
2 | bin
3 | obj
4 | Xlbin
5 | *.exe
6 | *.log
7 | *.bak
8 | *.user
9 | *.lnk
10 | *.pyc
11 | *.user
12 | *.xlt
13 | *.xls
--------------------------------------------------------------------------------
/Examples/AutoIt/ListLinksToExcel.au3:
--------------------------------------------------------------------------------
1 | ; AutoIt script example with Selenium
2 | ; https://www.autoitscript.com
3 | ;
4 |
5 | Func Main()
6 | ; Launch the browser and open an URL
7 | Dim $driver = ObjCreate("Selenium.FirefoxDriver")
8 | $driver.Get("https://en.wikipedia.org/wiki/Main_Page")
9 |
10 | ; List all links, remove duplicates and sort them
11 | Dim $links = $driver.FindElementsByCss("a").Attribute("href")
12 | $links.Distinct
13 | $links.Sort
14 |
15 | ; Launch Excel and create a Workbook
16 | Dim $excel = ObjCreate("Excel.Application")
17 | $excel.WorkBooks.Add ; Add a new workbook
18 | $excel.Visible = 1 ; Let Excel show itself
19 |
20 | ; Write the links in Excel and quit
21 | $links.ToExcel($excel.ActiveSheet, "Links")
22 | $driver.Quit
23 | EndFunc
24 |
25 | Main()
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Examples/Excel/CloudBrowserStack.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/Excel/CloudBrowserStack.xlsm
--------------------------------------------------------------------------------
/Examples/Excel/CloudSauceLab.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/Excel/CloudSauceLab.xlsm
--------------------------------------------------------------------------------
/Examples/Excel/Examples.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/Excel/Examples.xlsm
--------------------------------------------------------------------------------
/Examples/Excel/ExamplesNoRegistration.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/Excel/ExamplesNoRegistration.xlsm
--------------------------------------------------------------------------------
/Examples/Excel/ExamplesPageObject.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/Excel/ExamplesPageObject.xlsm
--------------------------------------------------------------------------------
/Examples/JavaScript/SimpleGoogleSearch(IE).js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/JavaScript/SimpleGoogleSearch(IE).js
--------------------------------------------------------------------------------
/Examples/VBScript/BasicAuthentication(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/BasicAuthentication(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/CaptureToPdf(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/CaptureToPdf(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/CaptureToPdf(PhantomJs).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/CaptureToPdf(PhantomJs).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/CompareRendering(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/CompareRendering(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/CompareRendering(PhantomJS).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/CompareRendering(PhantomJS).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/CustomProfileWith(Chrome).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/CustomProfileWith(Chrome).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/CustomProfileWith(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/CustomProfileWith(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/DownloadFile(Chrome).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/DownloadFile(Chrome).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/DownloadFile(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/DownloadFile(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/GmailSignIn(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/GmailSignIn(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/ListLinks(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/ListLinks(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/ListLinksToExcel(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/ListLinksToExcel(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/PageObject.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/PageObject.vbs
--------------------------------------------------------------------------------
/Examples/VBScript/Remoting(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/Remoting(Firefox).vbs
--------------------------------------------------------------------------------
/Examples/VBScript/SimpleGoogleSearch(Firefox).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Examples/VBScript/SimpleGoogleSearch(Firefox).vbs
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome.manifest:
--------------------------------------------------------------------------------
1 | content implicit-wait chrome/content/
2 |
3 | locale implicit-wait en-US chrome/locale/en-US/
4 |
5 | overlay chrome://selenium-ide/content/selenium-ide-overlay.xul chrome://implicit-wait/content/extension-loader.xul
6 | overlay chrome://selenium-ide/content/selenium-ide-common.xul chrome://implicit-wait/content/view/selenium-ide-overlay-iw.xul
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/content/extension-loader.xul:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | var ide_api = new API();
8 | ide_api.addPlugin("implicit-wait@florent.breheret");
9 | ide_api.addPluginProvidedIdeExtension("chrome://implicit-wait/content/implicit-wait-ide.js");
10 | ide_api.addPluginProvidedUserExtension("chrome://implicit-wait/content/implicit-wait-ext.js", "chrome://implicit-wait/content/implicit-wait-ide.xml");
11 |
12 |
13 |
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/content/implicit-wait-ide.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Florent Breheret
3 | * http://code.google.com/p/selenium-implicit-wait/
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | window.editor.implicitwait = {
19 | TIMEOUT_DEFAULT: 5000,
20 | timeout: 0,
21 | set enabled(value){ this.timeout = value ? this.TIMEOUT_DEFAULT : 0; }
22 | };
23 |
24 | /**
25 | * Handles the click event on the hourglass button
26 | */
27 | window.editor.window.document.getElementById("implicitwait-button").onclick = function(){
28 | window.editor.implicitwait.enabled = (this.checked ^= true);
29 | };
30 |
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/content/implicit-wait-ide.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Timeout in millisecond, set 0 to disable the implicit wait
6 |
7 | Specifies the amount of time it should wait when searching for an element if it is not immediately present.
8 | Exemple : setImplicitWait | 5000
9 |
10 |
11 |
12 |
13 | Timeout in millisecond, set 0 to disable the implicit wait
14 | a javascript logical expression that need to be true to execute each command.
15 |
16 | Specifies the amount of time it should wait for a condition to be true to continue to the next command.
17 | Exemple : setImplicitWaitCondition | 5000 | 1==1
18 | Conditions with known Ajax libraries :
19 |
20 | !window.Sys || !window.Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()
21 | !window.dojo || !window.dojo.io.XMLHTTPTransport.inFlight.length
22 | !window.Ajax || !window.Ajax.activeRequestCount
23 | !window.tapestry || !window.tapestry.isServingRequests()
24 | !window.jQuery || !window.jQuery.active
25 |
26 | PS : To check if the library is used, run the command getEval with the name of the library. Ex : getEval | alert( "Lib is present : " + ( typeof window.Ajax!='undefined') )
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/content/view/implicitwait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/FirefoxAddons/implicit-wait/chrome/content/view/implicitwait.png
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/content/view/selenium-ide-overlay-iw.css:
--------------------------------------------------------------------------------
1 | #implicitwait-button{
2 | list-style-image: url("implicitwait.png");
3 | -moz-image-region: rect(0px 18px 16px 0px);
4 | }
5 | #implicitwait-button[checked="true"]{
6 | -moz-image-region: rect(16px 18px 32px 0px);
7 | background-color: rgba(225, 225, 225, 0.3);
8 | }
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/content/view/selenium-ide-overlay-iw.xul:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 | %browserDTD;
8 |
9 | %exportTcStatusDTD;
10 | ]>
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/chrome/locale/en-US/implicit-wait.dtd:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/FirefoxAddons/implicit-wait/install.rdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | implicit-wait@florent.breheret
5 | Selenium IDE: Implicit Wait
6 | 2.0.9.0
7 | Florent BREHERET
8 | Implicit wait functions for Selenium IDE
9 | 2
10 | http://code.google.com/p/selenium-implicit-wait
11 |
12 |
13 | {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
14 |
15 | 3.0
16 | 35.0
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/FirefoxAddons/install.rdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 32
5 |
6 |
--------------------------------------------------------------------------------
/FirefoxAddons/vb-format/chrome.manifest:
--------------------------------------------------------------------------------
1 | # chrome.manifest for production
2 | content vb-formatters chrome/content/
3 |
4 | overlay chrome://selenium-ide/content/selenium-ide-overlay.xul chrome://vb-formatters/content/formats/format-loader.xul
5 |
--------------------------------------------------------------------------------
/FirefoxAddons/vb-format/chrome/content/formats/format-loader.xul:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 | var ide_api = new API();
10 | ide_api.addPlugin("vbformatters@florent.breheret");
11 | ide_api.addPluginProvidedFormatter("vbawdformatter", "VBA / WebDriver", "chrome://vb-formatters/content/formats/vba-wd.js");
12 | ide_api.addPluginProvidedFormatter("vbswdformatter", "VBS / WebDriver", "chrome://vb-formatters/content/formats/vbs-wd.js");
13 |
14 |
--------------------------------------------------------------------------------
/FirefoxAddons/vb-format/chrome/content/formats/vba-rc.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/FirefoxAddons/vb-format/chrome/content/formats/vba-rc.js
--------------------------------------------------------------------------------
/FirefoxAddons/vb-format/chrome/content/formats/vbs-rc.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/FirefoxAddons/vb-format/chrome/content/formats/vbs-rc.js
--------------------------------------------------------------------------------
/FirefoxAddons/vb-format/install.rdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | vbformatters@florent.breheret
5 | Selenium IDE: VBA/VBS Formatters
6 | 2.0.9.0
7 | Florent BREHERET
8 | VBA/VBS code formatters for Selenium IDE
9 | 2
10 | https://github.com/florentbr/SeleniumBasic
11 |
12 |
13 | {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
14 |
15 | 3.0
16 | 40.0
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, florentbr
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of SeleniumBasic nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SeleniumBasic
2 | A Selenium based browser automation framework for VB.Net, Visual Basic Applications and VBScript
3 |
--------------------------------------------------------------------------------
/Scripts/QuickTest.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/QuickTest.vbs
--------------------------------------------------------------------------------
/Scripts/RunCleaner.vbs:
--------------------------------------------------------------------------------
1 |
2 | ' Utility script to
3 | ' Call driver.Quit on each active session
4 | ' Terminate all the background drivers (chromedriver, iedriver, operadriver, phantomjs)
5 | ' Delete the temporary folder (%TEMP%\Selenium)
6 |
7 | Sub Main()
8 | Call QuitSessions
9 | Call TerminateDrivers
10 | Call DeleteTemporaryFolder
11 | Wscript.Echo "Done!"
12 | End Sub
13 |
14 | 'Quits all the registered sessions
15 | Sub QuitSessions()
16 | Err.Clear
17 | On Error Resume Next
18 | Do
19 | GetObject("Selenium.WebDriver").Quit
20 | Loop Until Err.Number
21 | End Sub
22 |
23 | 'Terminates all the drivers and all the child processes
24 | Sub TerminateDrivers()
25 | names = Array("chromedriver.exe", "iedriver.exe", "operadriver.exe", "phantomjs.exe", "edgedriver.exe")
26 | Set mgt = GetObject("winmgmts:")
27 | On Error Resume Next
28 | For Each p In mgt.ExecQuery("Select * from Win32_Process Where Name='" & Join(names, "' Or Name='") & "'")
29 | For Each cp In mgt.ExecQuery("Select * from Win32_Process Where ParentProcessId=" & p.ProcessId)
30 | cp.Terminate
31 | Next
32 | p.Terminate
33 | Next
34 | End Sub
35 |
36 | 'Deletes all the files and folders in "%TEMP%\Selenium"
37 | Sub DeleteTemporaryFolder()
38 | Set sho = CreateObject("WScript.Shell")
39 | Set fso = CreateObject("Scripting.FileSystemObject")
40 | folder = sho.ExpandEnvironmentStrings("%TEMP%\Selenium")
41 | If fso.FolderExists(folder) Then
42 | Set folderObj = fso.GetFolder(folder)
43 | On Error Resume Next
44 | For Each subfolderObj in folderObj.SubFolders
45 | subfolderObj.Delete True
46 | Next
47 | For Each fileObj in folderObj.Files
48 | fileObj.Delete True
49 | Next
50 | folderObj.Delete True
51 | End If
52 | End Sub
53 |
54 | Call Main
55 |
--------------------------------------------------------------------------------
/Scripts/StartChrome.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartChrome.vbs
--------------------------------------------------------------------------------
/Scripts/StartChromeDebug.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartChromeDebug.vbs
--------------------------------------------------------------------------------
/Scripts/StartEdge.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartEdge.vbs
--------------------------------------------------------------------------------
/Scripts/StartFirefox.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartFirefox.vbs
--------------------------------------------------------------------------------
/Scripts/StartInternetExplorer.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartInternetExplorer.vbs
--------------------------------------------------------------------------------
/Scripts/StartOpera.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartOpera.vbs
--------------------------------------------------------------------------------
/Scripts/StartPhantomJS.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Scripts/StartPhantomJS.vbs
--------------------------------------------------------------------------------
/Selenium.Tests/Internals/BaseBrowsers.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using System;
3 |
4 | namespace Selenium.Tests.Internals {
5 |
6 | public enum Browser {
7 | Firefox, Chrome, Opera, IE, PhantomJS
8 | }
9 |
10 | abstract class BaseBrowsers {
11 |
12 | public readonly object Fixture;
13 |
14 | protected WebDriver driver;
15 | protected Keys Keys = new Keys();
16 | protected By By = new By();
17 |
18 | public BaseBrowsers(Browser browser) {
19 | WebServer.StartServer(@"..\..\Pages");
20 | this.driver = GetBrowserInstance(browser);
21 | this.driver.BaseUrl = WebServer.BaseUri;
22 | this.Fixture = browser;
23 | }
24 |
25 | [TestFixtureTearDown]
26 | public void TestFixtureTearDown() {
27 | driver.Quit();
28 | }
29 |
30 | private string GetBrowserTypeLib(Browser browser) {
31 | switch (browser) {
32 | case Browser.Firefox: return "Selenium.FirefoxDriver";
33 | case Browser.Chrome: return "Selenium.ChromeDriver";
34 | case Browser.Opera: return "Selenium.OperaDriver";
35 | case Browser.IE: return "Selenium.IEDriver";
36 | case Browser.PhantomJS: return "Selenium.PhantomJSDriver";
37 | }
38 | throw new Exception("Browser not supported: " + browser.ToString());
39 | }
40 |
41 | private WebDriver GetBrowserInstance(Browser browser) {
42 | switch (browser) {
43 | case Browser.Firefox: return new Selenium.FirefoxDriver();
44 | case Browser.Chrome: return new Selenium.ChromeDriver();
45 | case Browser.Opera: return new Selenium.OperaDriver();
46 | case Browser.IE: return new Selenium.IEDriver();
47 | case Browser.PhantomJS: return new Selenium.PhantomJSDriver();
48 | }
49 | throw new Exception("Browser not supported: " + browser.ToString());
50 | }
51 |
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/Selenium.Tests/Internals/BaseExcel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Threading;
4 | using TestFixtureSetUp = NUnit.Framework.TestFixtureSetUpAttribute;
5 | using TestFixtureTearDown = NUnit.Framework.TestFixtureTearDownAttribute;
6 |
7 | namespace Selenium.Tests.Internals {
8 |
9 | abstract class BaseExcel {
10 |
11 | protected COM excel;
12 | protected COM workbooks;
13 | protected COM workbook;
14 | protected COM worksheets;
15 | protected COM worksheet;
16 |
17 | [TestFixtureSetUp]
18 | public void TestFixtureSetUp() {
19 |
20 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
21 | var type = Type.GetTypeFromProgID("Excel.Application");
22 | var instance = Activator.CreateInstance(type);
23 | excel = new COM(instance);
24 | //_xl.set("Visible", true);
25 | workbooks = excel.get("Workbooks");
26 | workbook = workbooks.invoke("Add", Type.Missing);
27 | worksheets = workbook.get("Sheets");
28 | worksheet = workbook.get("ActiveSheet");
29 | }
30 |
31 | [TestFixtureTearDown]
32 | public void TestFixtureTearDown() {
33 | workbook.invoke("Close", false, Type.Missing, Type.Missing);
34 | excel.invoke("Quit");
35 | worksheet.Dispose();
36 | workbook.Dispose();
37 | workbooks.Dispose();
38 | excel.Dispose();
39 | foreach (var p in System.Diagnostics.Process.GetProcessesByName("excel")) {
40 | p.Kill();
41 | p.Dispose();
42 | }
43 | }
44 |
45 | public void addSheet() {
46 | worksheet = worksheets.invoke("Add", Type.Missing, Type.Missing, Type.Missing, Type.Missing);
47 | }
48 |
49 | public void setValue(string range, object[,] values) {
50 | var rg = worksheet.get("Range", range, Type.Missing);
51 | rg.set("Value", values);
52 | }
53 |
54 | public object getValue(string range) {
55 | var rg = worksheet.get("Range", range, Type.Missing);
56 | return rg.get("Value").Value;
57 | }
58 |
59 | public object getRange(string range) {
60 | return worksheet.get("Range", range, Type.Missing).Value;
61 | }
62 |
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/Selenium.Tests/Internals/COM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.Tests.Internals {
6 |
7 | class COM {
8 |
9 | public static object CreateObject(string app) {
10 | Type type = Type.GetTypeFromProgID(app);
11 | if (type == null)
12 | throw new Exception(string.Format("Application not registered: {0}", app));
13 | return Activator.CreateInstance(type);
14 | }
15 |
16 | public static void Dispose(object obj) {
17 | if (Marshal.IsComObject(obj)) {
18 | while (Marshal.ReleaseComObject(obj) > 0) ;
19 | }
20 | }
21 |
22 | private object _obj;
23 | private Type _type;
24 |
25 | public COM(object obj) {
26 | if ((_obj = obj) != null)
27 | _type = obj.GetType();
28 | }
29 |
30 | public object Value {
31 | get {
32 | return _obj;
33 | }
34 | }
35 |
36 | public COM invoke(string method, params object[] args) {
37 | var result = _type.InvokeMember(method, BindingFlags.InvokeMethod, null, _obj, args);
38 | return new COM(result);
39 | }
40 |
41 | public COM get(string prop, params object[] args) {
42 | var result = _type.InvokeMember(prop, BindingFlags.GetProperty, null, _obj, args);
43 | return new COM(result);
44 | }
45 |
46 | public void set(string prop, params object[] args) {
47 | _type.InvokeMember(prop, BindingFlags.SetProperty, null, _obj, args);
48 | }
49 |
50 | public void Dispose() {
51 | try {
52 | Marshal.ReleaseComObject(_obj);
53 | } catch { }
54 | }
55 |
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/Selenium.Tests/Internals/IgnoreFixtureAttribute.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using System;
3 | using A = NUnit.Framework.Assert;
4 |
5 | namespace Selenium.Tests.Internals {
6 |
7 | [AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple=true)]
8 | public class IgnoreFixtureAttribute : Attribute, ITestAction {
9 |
10 | private object _fixture;
11 | private string _reason;
12 |
13 | public IgnoreFixtureAttribute(object fixture, string reason) {
14 | _fixture = fixture;
15 | _reason = reason;
16 | }
17 |
18 | public void BeforeTest(TestDetails testDetails) {
19 | BaseBrowsers tb = testDetails.Fixture as BaseBrowsers;
20 | if (tb != null && _fixture.Equals(tb.Fixture))
21 | A.Ignore(string.Format("{0}: {1}", _fixture, _reason));
22 | }
23 |
24 | public void AfterTest(TestDetails testDetails) {
25 |
26 | }
27 |
28 | public ActionTargets Targets {
29 | get {
30 | return ActionTargets.Test | ActionTargets.Suite;
31 | }
32 | }
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/eiffel-tower.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Selenium.Tests/Pages/eiffel-tower.jpg
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/findby.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Div1
10 | Div2
11 | Div3
12 | Div4
13 | Div5
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/frame1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Frame1
7 |
8 |
9 | Frame1
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/frame2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Frame2
7 |
8 |
9 | Frame2
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/frame3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Frame3
7 |
8 |
9 | Frame3
10 |
11 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
20 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/links.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Links
7 |
8 |
9 |
21 |
22 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/select.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Select
12 | Select
13 |
14 |
15 | Option One
16 | Option Two
17 | Option Three
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/table.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Table
7 |
8 |
9 |
69 |
70 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/win1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Window1
7 |
8 |
9 | Window1
10 |
11 | Links
12 | Window1
13 | Window2
14 | Window3
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/win2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Window2
7 |
8 |
9 | Window2
10 |
11 | Links
12 | Window1
13 | Window2
14 | Window3
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Selenium.Tests/Pages/win3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Window3
7 |
8 |
9 | Window3
10 |
11 | Links
12 | Window1
13 | Window2
14 | Window3
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Selenium.Tests/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace Sample {
4 |
5 | class Program {
6 |
7 | static void Main(string[] args) {
8 | string[] my_args = {
9 | Assembly.GetExecutingAssembly().Location,
10 | "/run:Selenium.Tests"
11 | };
12 | int returnCode = NUnit.ConsoleRunner.Runner.Main(my_args);
13 |
14 | return;
15 | }
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Selenium.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Selenium.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Selenium.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0277FC34-FD1B-4616-BB19-27D8C6D1C7AF")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Actions.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using SetUp = NUnit.Framework.SetUpAttribute;
3 | using TestCase = NUnit.Framework.TestCaseAttribute;
4 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
5 |
6 | namespace Selenium.Tests {
7 |
8 | [TestFixture(Browser.Firefox)]
9 | [TestFixture(Browser.Opera)]
10 | [TestFixture(Browser.Chrome)]
11 | [TestFixture(Browser.IE)]
12 | [TestFixture(Browser.PhantomJS)]
13 | class TS_Actions : BaseBrowsers {
14 |
15 | public TS_Actions(Browser browser)
16 | : base(browser) { }
17 |
18 | [SetUp]
19 | public void SetUp() {
20 | driver.Get("/input.html");
21 | }
22 |
23 | [TestCase]
24 | public void ShouldPerformActionsWithoutFailures() {
25 | var ele = driver.FindElementById("input__search");
26 | driver.Actions
27 | .Click(ele)
28 | .Click()
29 | .ClickAndHold()
30 | .Release()
31 | .ClickAndHold(ele)
32 | .Release()
33 | .ClickDouble()
34 | .ClickDouble(ele)
35 | .DragAndDrop(ele, ele)
36 | .DragAndDropByOffset(ele, 10, 10)
37 | .KeyDown(Keys.Control, ele)
38 | .KeyUp(Keys.Control)
39 | .MoveByOffset(30, 87)
40 | .MoveToElement(ele)
41 | .SendKeys("abcd")
42 | .Wait(0)
43 | .ClickContext()
44 | .ClickContext(ele)
45 | .Perform();
46 | }
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Capture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Selenium.Tests.Internals;
4 | using A = NUnit.Framework.Assert;
5 | using TestCase = NUnit.Framework.TestCaseAttribute;
6 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
7 |
8 | namespace Selenium.Tests {
9 |
10 | [TestFixture(Browser.Firefox)]
11 | [TestFixture(Browser.Opera)]
12 | [TestFixture(Browser.Chrome)]
13 | [TestFixture(Browser.IE)]
14 | [TestFixture(Browser.PhantomJS)]
15 | class TS_Capture : BaseBrowsers {
16 |
17 | public TS_Capture(Browser browser)
18 | : base(browser) { }
19 |
20 | [TestCase]
21 | public void ShouldCaptureToFile() {
22 | driver.Get("/elements.html");
23 | var imgname = string.Format("wd-capt-{0}-{1}.png"
24 | , Fixture.ToString().ToLower()
25 | , DateTime.Now.Ticks.ToString());
26 |
27 | driver.TakeScreenshot().SaveAs(@"%temp%\" + imgname);
28 | var file = new FileInfo(Environment.ExpandEnvironmentVariables(@"%temp%\" + imgname));
29 | A.Greater(file.Length, 10000);
30 | file.Delete();
31 | }
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Excel.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using System.Threading;
3 | using Selenium.Tests.Internals;
4 | using A = NUnit.Framework.Assert;
5 | using Test = NUnit.Framework.TestAttribute;
6 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
7 | using TestFixtureSetUp = NUnit.Framework.TestFixtureSetUpAttribute;
8 | using TestFixtureTearDown = NUnit.Framework.TestFixtureTearDownAttribute;
9 |
10 | namespace Selenium.Tests {
11 |
12 | [TestFixture]
13 | class TS_Excel : BaseExcel {
14 |
15 | [Test]
16 | public void TC_ShouldReadAndWriteDataTable() {
17 | addSheet();
18 | setValue("A1:C5", new object[,]{
19 | {"A", "B", "C"},
20 | {0, 10.7, "val0"},
21 | {1, 10, "val1"},
22 | {2, 18.7, "val2"},
23 | {3, 18.8, "val3"}
24 | });
25 | var dt = new Table();
26 |
27 | var data = dt.From("A1", true).Where("B > 11", null);
28 | A.AreEqual(2, dt.Count);
29 |
30 | addSheet();
31 | data.ToExcel("A1");
32 | A.AreEqual("A", getValue("A1"));
33 | A.AreEqual("C", getValue("C1"));
34 | A.AreEqual(3, getValue("A3"));
35 | A.AreEqual("val3", getValue("C3"));
36 | }
37 |
38 | [Test]
39 | public void TC_ShouldWriteList() {
40 | addSheet();
41 | var target = getRange("A1");
42 |
43 | var list = new List();
44 | list.AddRange(new object[] { 665, 987897, 909 });
45 | list.ToExcel(target, "Mytitle", true);
46 |
47 | A.AreEqual("Mytitle", getValue("A1"));
48 | A.AreEqual(665, getValue("A2"));
49 | A.AreEqual(909, getValue("A4"));
50 | A.AreEqual(null, getValue("A5"));
51 | }
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_ExecuteScript.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using CollectionAssert = NUnit.Framework.CollectionAssert;
4 | using SetUp = NUnit.Framework.SetUpAttribute;
5 | using TestCase = NUnit.Framework.TestCaseAttribute;
6 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
7 |
8 | namespace Selenium.Tests {
9 |
10 | [TestFixture(Browser.Firefox)]
11 | [TestFixture(Browser.Opera)]
12 | [TestFixture(Browser.Chrome)]
13 | [TestFixture(Browser.IE)]
14 | [TestFixture(Browser.PhantomJS)]
15 | class TS_ExecuteScript : BaseBrowsers {
16 |
17 | public TS_ExecuteScript(Browser browser)
18 | : base(browser) { }
19 |
20 | [SetUp]
21 | public void SetUp() {
22 | driver.Get("/elements.html");
23 | }
24 |
25 | [TestCase]
26 | public void ShouldProcessWebElement() {
27 | //Webelement
28 | var ele = driver.FindElementById("input__text");
29 | var resEle = (WebElement)driver.ExecuteScript("return arguments[0];", ele);
30 | A.True(ele.Equals(resEle));
31 | }
32 |
33 | [TestCase]
34 | public void ShouldProcessWebElements() {
35 | //Webelements
36 | var eles = driver.FindElementsByTag("input");
37 | var resEles = (WebElements)driver.ExecuteScript("return arguments;", eles);
38 | A.AreEqual(eles.Count, resEles.Count);
39 | A.True(eles.First().Equals(resEles.First()));
40 | }
41 |
42 | [TestCase]
43 | public void ShouldProcessPrimitive() {
44 | //prinmitive int
45 | var res = driver.ExecuteScript("return arguments[0] + 3;", 8);
46 | A.AreEqual(11, res);
47 |
48 | //prinmitive double
49 | var valDouble = driver.ExecuteScript("return 1e-8;");
50 | A.AreEqual(1e-8, valDouble);
51 | }
52 |
53 | [TestCase]
54 | public void ShouldProcessDictionary() {
55 | //Dictionary
56 | var dict = new Selenium.Dictionary();
57 | dict.Add("a", 987);
58 | var resDict = (Dictionary)driver.ExecuteScript("return arguments[0];", dict);
59 | CollectionAssert.AreEquivalent(dict, resDict);
60 | }
61 |
62 | [TestCase]
63 | public void ShouldProcessList() {
64 | //List
65 | var list = new Selenium.List();
66 | list.Add(987);
67 | var resList = (Selenium.List)driver.ExecuteScript("return arguments;", list);
68 | CollectionAssert.AreEquivalent(list, resList);
69 | }
70 |
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Manage.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using SetUp = NUnit.Framework.SetUpAttribute;
4 | using TestCase = NUnit.Framework.TestCaseAttribute;
5 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
6 |
7 | namespace Selenium.Tests {
8 |
9 | [TestFixture(Browser.Firefox)]
10 | [TestFixture(Browser.Opera)]
11 | [TestFixture(Browser.Chrome)]
12 | [TestFixture(Browser.IE)]
13 | [TestFixture(Browser.PhantomJS)]
14 | class TS_Manage : BaseBrowsers {
15 |
16 | public TS_Manage(Browser browser)
17 | : base(browser) { }
18 |
19 | [SetUp]
20 | public void SetUp() {
21 | driver.Get("/input.html");
22 | }
23 |
24 | [TestCase]
25 | [IgnoreFixture(Browser.IE, "Not supported")]
26 | public void ShouldAddAndDeleteCookies() {
27 | var manage = driver.Manage;
28 | A.AreEqual(0, manage.Cookies.Count);
29 |
30 | manage.AddCookie("ck_name", "ck_value", null, "/", "2017-06-15T12:08:03");
31 | var cookies = manage.Cookies;
32 | A.AreEqual(1, manage.Cookies.Count);
33 |
34 | var cookie = cookies[0];
35 | A.AreEqual("ck_name", cookie.Name);
36 | A.AreEqual("ck_value", cookie.Value);
37 | A.AreEqual("localhost", cookie.Domain);
38 | A.AreEqual("/", cookie.Path);
39 | A.AreEqual("2017-06-15T12:08:03", cookie.Expiry);
40 |
41 | driver.Manage.DeleteAllCookies();
42 | A.AreEqual(0, manage.Cookies.Count);
43 | }
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Mouse.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using SetUp = NUnit.Framework.SetUpAttribute;
4 | using TestCase = NUnit.Framework.TestCaseAttribute;
5 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
6 |
7 | namespace Selenium.Tests {
8 |
9 | [TestFixture(Browser.Firefox)]
10 | [TestFixture(Browser.Opera)]
11 | [TestFixture(Browser.Chrome)]
12 | [TestFixture(Browser.IE)]
13 | [TestFixture(Browser.PhantomJS)]
14 | class TS_Mouse : BaseBrowsers {
15 |
16 | public TS_Mouse(Browser browser)
17 | : base(browser) { }
18 |
19 | [SetUp]
20 | public void SetUp() {
21 | driver.Get("/input.html");
22 | }
23 |
24 | [TestCase]
25 | public void ShouldDoubleClick() {
26 | var ele = driver.FindElementById("input__search");
27 | var mouse = driver.Mouse;
28 |
29 | mouse.MoveTo(ele, 50);
30 | mouse.Click();
31 | mouse.ClickAndHold();
32 | mouse.Release();
33 | }
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_PDF.cs:
--------------------------------------------------------------------------------
1 | using A = NUnit.Framework.Assert;
2 | using Test = NUnit.Framework.TestAttribute;
3 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
4 |
5 | namespace Selenium.Tests {
6 |
7 | [TestFixture]
8 | class TS_PDF {
9 |
10 | [Test]
11 | public void ShouldCreatePDF() {
12 | string tempPath = System.IO.Path.GetTempPath() + @"\my-capture.pdf";
13 | if (System.IO.File.Exists(tempPath))
14 | System.IO.File.Delete(tempPath);
15 |
16 | var pdf = new PdfFile();
17 |
18 | //Define the PDF page size and margins
19 |
20 | pdf.SetPageSize(210, 297, "mm");
21 | pdf.SetMargins(10, 10, 10, 15, "mm");
22 |
23 | //Add a title and informations to the PDF
24 | pdf.AddTextCenter(text: "Selenium search result", size: 20, bold: true);
25 | pdf.AddTitle("Title A");
26 | pdf.AddText(text: "Description = Search for Eiffel tower", size: 9, color: "DarkBlue");
27 | pdf.AddLink("http://www.test.com", "Test link");
28 |
29 | //Add a text paragraph to the PDF file
30 | string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet libero arcu, et molestie purus. Ut in sem lacus, sit amet rhoncus erat. In aliquet arcu at nunc porta sollicitudin. Cras ante nisl, hendrerit quis bibendum quis, egestas vitae mi. Donec ac felis at eros placerat iaculis. Nam quam sapien, scelerisque vel bibendum et, mollis sit amet augue. Nullam egestas, lectus ut laoreet vulputate, neque quam vestibulum sapien, ut vehicula nunc metus et nulla. Curabitur ac lorem augue. Nullam quis justo eu arcu volutpat ultrices ac at orci.";
31 | pdf.AddText(text: text, size: 10);
32 |
33 | pdf.AddPage();
34 |
35 | //Take a screenschot and add it to the PDF file
36 | using (var img = new Utils().TakeScreenShot()) {
37 | pdf.AddBookmark("Bookmark");
38 | pdf.AddTitle("Capture A");
39 | pdf.AddImage(img, false);
40 | }
41 |
42 | pdf.SaveAs(tempPath);
43 |
44 | A.True(System.IO.File.Exists(tempPath));
45 | A.Greater(new System.IO.FileInfo(tempPath).Length, 25000);
46 |
47 | }
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Scraping.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using TestCase = NUnit.Framework.TestCaseAttribute;
4 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
5 |
6 | namespace Selenium.Tests {
7 |
8 | [TestFixture(Browser.Firefox)]
9 | [TestFixture(Browser.Opera)]
10 | [TestFixture(Browser.Chrome)]
11 | [TestFixture(Browser.IE)]
12 | [TestFixture(Browser.PhantomJS)]
13 | class TS_Scraping : BaseBrowsers {
14 |
15 | public TS_Scraping(Browser browser)
16 | : base(browser) { }
17 |
18 | [TestCase]
19 | public void ShouldScrapTextFromTable() {
20 | driver.Get("/table.html");
21 | var element = driver.FindElementByCss("#table table");
22 | TableElement table = element.AsTable();
23 | var data = table.Data();
24 | A.AreEqual(data[1, 1], "Table Heading 1");
25 | A.AreEqual(data[6, 5], "Table Footer 5");
26 | }
27 |
28 | [TestCase]
29 | public void ShouldScrapTextFromElements() {
30 | driver.Get("/table.html");
31 | var elements = driver.FindElementsByCss("thead th");
32 | var data = elements.Text();
33 | A.AreEqual(data[0], "Table Heading 1");
34 | }
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Select.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using SetUp = NUnit.Framework.SetUpAttribute;
4 | using TestCase = NUnit.Framework.TestCaseAttribute;
5 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
6 |
7 | namespace Selenium.Tests {
8 |
9 | [TestFixture(Browser.Firefox)]
10 | [TestFixture(Browser.Opera)]
11 | [TestFixture(Browser.Chrome)]
12 | [TestFixture(Browser.IE)]
13 | [TestFixture(Browser.PhantomJS)]
14 | class TS_Select : BaseBrowsers {
15 |
16 | public TS_Select(Browser browser)
17 | : base(browser) { }
18 |
19 | [SetUp]
20 | public void SetUp() {
21 | driver.Get("/select.html");
22 | }
23 |
24 | [TestCase]
25 | public void ShouldListItems() {
26 | var ele = driver.FindElementById("select").AsSelect();
27 | List lst = ele.Options.Text();
28 | A.AreEqual("Option One", lst.First());
29 | A.AreEqual("Option Three", lst.Last());
30 | }
31 |
32 | [TestCase]
33 | public void ShouldSelectByIndex() {
34 | var ele = driver.FindElementById("select").AsSelect();
35 | ele.SelectByIndex(1);
36 | A.AreEqual("Option Two", ele.SelectedOption.Text());
37 | }
38 |
39 | [TestCase]
40 | public void ShouldSelectByText() {
41 | var ele = driver.FindElementById("select").AsSelect();
42 | ele.SelectByText("Option Two");
43 | A.AreEqual("Option Two", ele.SelectedOption.Text());
44 | }
45 |
46 | [TestCase]
47 | public void ShouldSelectByValue() {
48 | var ele = driver.FindElementById("select").AsSelect();
49 | ele.SelectByValue("opt2");
50 | A.AreEqual("opt2", ele.SelectedOption.Attribute("value"));
51 | }
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Verify.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using Selenium.ComInterfaces;
3 | using Selenium.Tests.Internals;
4 | using A = NUnit.Framework.Assert;
5 |
6 | namespace Selenium.Tests {
7 |
8 | [TestFixture]
9 | public class TS_Verify {
10 |
11 | _Verify verify = new Verify();
12 |
13 | [Test]
14 | public void ShouldVerifyTrueOK() {
15 | var res = verify.True(true);
16 | A.AreEqual("OK", res);
17 | }
18 |
19 | [Test]
20 | public void ShouldVerifyTrueKO() {
21 | var res = verify.True(false);
22 | A.AreEqual("KO expected=True was=False", res);
23 | }
24 |
25 | [Test]
26 | public void ShouldVerifyEnumEqual() {
27 | var res = verify.Equals("a;b;c", new string[] { "a", "b", "c" }, "");
28 | A.AreEqual("OK", res);
29 | }
30 |
31 | [Test]
32 | public void ShouldVerifyEnumNotEqual() {
33 | var res = verify.Equals("a;c;b", new string[] { "a", "b", "c" }, null);
34 | A.AreEqual("KO expected=\"a;c;b\" was=[a,b,c]", res);
35 | }
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Window.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using SetUp = NUnit.Framework.SetUpAttribute;
4 | using TestCase = NUnit.Framework.TestCaseAttribute;
5 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
6 |
7 | namespace Selenium.Tests {
8 |
9 | [TestFixture(Browser.Firefox)]
10 | [TestFixture(Browser.Opera)]
11 | [TestFixture(Browser.Chrome)]
12 | [TestFixture(Browser.IE)]
13 | [TestFixture(Browser.PhantomJS)]
14 | class TS_Window : BaseBrowsers {
15 |
16 | public TS_Window(Browser browser)
17 | : base(browser) { }
18 |
19 | [SetUp]
20 | public void SetUp() {
21 | driver.Get("/win1.html");
22 | }
23 |
24 | [TestCase]
25 | public void ShouldDisplayMaximized() {
26 | var win = driver.Window;
27 | win.SetSize(800, 600);
28 |
29 | win.Maximize();
30 | var size = win.Size();
31 | A.Greater(size.Width, 900);
32 | A.Greater(size.Height, 700);
33 | }
34 |
35 | [TestCase]
36 | public void ShouldGetAndSetSize() {
37 | var win = driver.Window;
38 | win.SetSize(800, 600);
39 | var size = win.Size();
40 | A.AreEqual(800, size.Width);
41 | A.AreEqual(600, size.Height);
42 | }
43 |
44 | [TestCase]
45 | [IgnoreFixture(Browser.PhantomJS, "Not supported")]
46 | public void ShouldGetAndSetPosition() {
47 | var win = driver.Window;
48 | win.SetPosition(17, 23);
49 | var pos = win.Position();
50 | A.AreEqual(17, pos.X);
51 | A.AreEqual(23, pos.Y);
52 | }
53 |
54 | [TestCase]
55 | public void ShouldGetTitle() {
56 | var win = driver.Window;
57 | A.AreEqual("Window1", win.Title);
58 | }
59 |
60 | [TestCase]
61 | [IgnoreFixture(Browser.PhantomJS, "Not supported")]
62 | [IgnoreFixture(Browser.Opera, "Issue #14")]
63 | public void ShouldCloseWindow() {
64 | var win1 = driver.Window;
65 | driver.FindElementByLinkText("Window2").Click();
66 | driver.SwitchToNextWindow().Close();
67 | win1.Activate();
68 | A.AreEqual(1, driver.Windows.Count);
69 | }
70 |
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_Windows.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Tests.Internals;
2 | using A = NUnit.Framework.Assert;
3 | using SetUp = NUnit.Framework.SetUpAttribute;
4 | using TearDown = NUnit.Framework.TearDownAttribute;
5 | using TestCase = NUnit.Framework.TestCaseAttribute;
6 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
7 |
8 | namespace Selenium.Tests {
9 |
10 | [TestFixture(Browser.Firefox)]
11 | [TestFixture(Browser.Opera)]
12 | [TestFixture(Browser.Chrome)]
13 | [TestFixture(Browser.IE)]
14 | //[TestFixture(Browser.PhantomJS)]
15 | class TS_Windows : BaseBrowsers {
16 |
17 | public TS_Windows(Browser browser)
18 | : base(browser) { }
19 |
20 | [TearDown]
21 | public void TearDown() {
22 | driver.Quit();
23 | }
24 |
25 | [TestCase]
26 | [IgnoreFixture(Browser.Opera, "Issue #14")]
27 | public void ShouldSwitchToNextWindows() {
28 | driver.Get("/win1.html");
29 | driver.Wait(100);
30 | A.AreEqual("Window1", driver.Title);
31 |
32 | driver.FindElementByLinkText("Window2").Click();
33 | driver.SwitchToNextWindow();
34 | A.AreEqual("Window2", driver.Title);
35 |
36 | driver.FindElementByLinkText("Window3").Click();
37 | driver.SwitchToNextWindow();
38 | A.AreEqual("Window3", driver.Title);
39 |
40 | driver.SwitchToPreviousWindow();
41 | A.AreEqual("Window2", driver.Title);
42 | }
43 |
44 | [TestCase]
45 | [IgnoreFixture(Browser.Opera, "Issue #14")]
46 | public void ShouldSwitchToWindows() {
47 | driver.Get("/win1.html");
48 | A.AreEqual("Window1", driver.Title);
49 |
50 | driver.FindElementByLinkText("Window2").Click();
51 | driver.SwitchToWindowByTitle("Window2");
52 | A.AreEqual("Window2", driver.Title);
53 |
54 | driver.FindElementByLinkText("Window3").Click();
55 | driver.SwitchToWindowByTitle("Window3");
56 | A.AreEqual("Window3", driver.Title);
57 |
58 | driver.SwitchToWindowByName("win2");
59 | A.AreEqual("Window2", driver.Title);
60 |
61 | driver.SwitchToWindowByName("win3");
62 | A.AreEqual("Window3", driver.Title);
63 | }
64 |
65 | [TestCase]
66 | [IgnoreFixture(Browser.IE, "Not supported")]
67 | [IgnoreFixture(Browser.Opera, "Issue #14")]
68 | public void ShouldOpenLinkInNewWindow() {
69 | driver.Get("/links.html");
70 | driver.FindElementByLinkText("Win1", 5000).Click(Keys.Shift);
71 | driver.SwitchToNextWindow();
72 | driver.Wait(5000);
73 | A.AreEqual("Window1", driver.Title);
74 | }
75 |
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/Selenium.Tests/TS_zip.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Zip;
2 | using System;
3 | using System.IO;
4 | using A = NUnit.Framework.Assert;
5 | using Test = NUnit.Framework.TestAttribute;
6 | using TestFixture = NUnit.Framework.TestFixtureAttribute;
7 |
8 | namespace Selenium.Tests {
9 |
10 | [TestFixture]
11 | class TS_Zip {
12 |
13 | private void CreateTextFile(string path, string text){
14 | using (StreamWriter sw = File.CreateText(path))
15 | sw.Write(text);
16 | }
17 |
18 | [Test]
19 | public void ShouldZipAndUnzipNoCompression() {
20 | ShouldZipAndUnzipWithoutLose(false);
21 | }
22 |
23 | [Test]
24 | public void ShouldZipAndUnzipWithCompression() {
25 | ShouldZipAndUnzipWithoutLose(true);
26 | }
27 |
28 | private void ShouldZipAndUnzipWithoutLose(bool compress){
29 |
30 | string testfolder = Path.Combine(System.IO.Path.GetTempPath(), DateTime.Now.Ticks.ToString());
31 | Directory.CreateDirectory(testfolder);
32 |
33 | string path1 = Path.Combine(testfolder, "text1.txt");
34 | string path2 = Path.Combine(testfolder, "text2.txt");
35 |
36 | string text1 = "";
37 | string text2 = "START data\r\n ééúóáEN\u0247D";
38 |
39 | CreateTextFile(path1, text1);
40 | CreateTextFile(path2, text2);
41 |
42 | string zippath = Path.Combine(testfolder, "archive.zip");
43 | string extractdir = Path.Combine(testfolder, "extract");
44 | string path11 = Path.Combine(extractdir, "text1.txt");
45 | string path22 = Path.Combine(extractdir, "text2.txt");
46 |
47 | try {
48 | using (var zip = new ZipFile(compress)) {
49 | zip.AddFile(path1);
50 | zip.AddFile(path2);
51 | zip.SaveAs(zippath);
52 | }
53 |
54 | ZipFile.ExtractAll(zippath, extractdir);
55 |
56 | A.True(Directory.Exists(extractdir));
57 | A.True(File.Exists(path11));
58 | A.True(File.Exists(path22));
59 |
60 | var text11 = File.ReadAllText(path11);
61 | A.AreEqual(text1, text11);
62 |
63 | var text22 = File.ReadAllText(path22);
64 | A.AreEqual(text2, text22);
65 | } finally {
66 | Directory.Delete(testfolder, true);
67 | }
68 | }
69 |
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/Selenium.Tests/tests.nunit:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Alerts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-B51CB7C5A694")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Alert {
11 |
12 | [DispId(10), Description("Dismisses the alert.")]
13 | void Dismiss();
14 |
15 | [DispId(14), Description("Accepts the alert.")]
16 | void Accept();
17 |
18 | [DispId(24), Description("Sends keys to the alert.")]
19 | void SendKeys(string keysToSend);
20 |
21 | [DispId(43), Description("Gets the text of the alert.")]
22 | string Text { get; }
23 |
24 | [DispId(54), Description("Sets the user name and password in an alert prompting for credentials.")]
25 | Alert SetCredentials(string user, string password);
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Application.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-6E0522EA435E")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
11 | public interface _Application {
12 |
13 | [DispId(10), Description("")]
14 | Assert Assert { get; }
15 |
16 | [DispId(18), Description("")]
17 | Verify Verify { get; }
18 |
19 | [DispId(23), Description("")]
20 | Waiter Waiter { get; }
21 |
22 | [DispId(27), Description("")]
23 | Utils Utils { get; }
24 |
25 |
26 |
27 | [DispId(42), Description("")]
28 | By By { get; }
29 |
30 | [DispId(46), Description("")]
31 | Keys Keys { get; }
32 |
33 |
34 | [DispId(63), Description("")]
35 | WebDriver WebDriver();
36 |
37 | [DispId(65), Description("")]
38 | WebDriver ChromeDriver();
39 |
40 | [DispId(68), Description("")]
41 | WebDriver FirefoxDriver();
42 |
43 | [DispId(72), Description("")]
44 | WebDriver IEDriver();
45 |
46 | [DispId(75), Description("")]
47 | WebDriver OperaDriver();
48 |
49 | [DispId(78), Description("")]
50 | WebDriver PhantomJSDriver();
51 |
52 |
53 |
54 | [DispId(92), Description("")]
55 | Dictionary Dictionary();
56 |
57 | [DispId(95), Description("")]
58 | List List();
59 |
60 | [DispId(97), Description("")]
61 | Point Point(int x, int y);
62 |
63 | [DispId(102), Description("")]
64 | Size Size(int width, int height);
65 |
66 | [DispId(105), Description("")]
67 | Table Table();
68 |
69 |
70 | [DispId(120), Description("")]
71 | PdfFile PdfFile();
72 |
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Assert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-0EA52ACB97D1")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Assert {
11 |
12 | [DispId(564), Description("Raise an error if the value is true.")]
13 | void True(bool value, string failmessage = null);
14 |
15 | [DispId(567), Description("Raise an error if the value is false.")]
16 | void False(bool value, string failmessage = null);
17 |
18 | [DispId(574), Description("Raise an error if the objects are not equal.")]
19 | void Equals(object expected, object input, string failmessage = null);
20 |
21 | [DispId(579), Description("Raise an error if the objects are equal.")]
22 | void NotEquals(object expected, object input, string failmessage = null);
23 |
24 | [DispId(583), Description("Raise an error if the text matches the pattern.")]
25 | void Matches(string pattern, string input, string failmessage = null);
26 |
27 | [DispId(587), Description("Raise an error if the text does not match the pattern.")]
28 | void NotMatches(string pattern, string input, string failmessage = null);
29 |
30 | [DispId(589), Description("Raise an error if the text does not contain the value.")]
31 | void Contains(string value, string input, string failmessage = null);
32 |
33 | [DispId(608), Description("Raise an error.")]
34 | void Fail(string message = null);
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_By.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-A3DE5685A27E")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _By {
11 |
12 | [DispId(5), Description("Current strategy.")]
13 | string Strategy { get; }
14 |
15 | [DispId(7), Description("Value of the current strategy.")]
16 | string Value { get; }
17 |
18 | [DispId(20), Description("Finds elements based on the HTML class name attribute.")]
19 | By Class(string className);
20 |
21 | [DispId(21), Description("Finds elements using a CSS expression.")]
22 | By Css(string cssSelector);
23 |
24 | [DispId(22), Description("Finds elements based on the HTML id attribute.")]
25 | By Id(string id);
26 |
27 | [DispId(23), Description("Finds elements matching the given text.")]
28 | By LinkText(string linkText);
29 |
30 | [DispId(24), Description("Finds elements based on the HTML name attribute.")]
31 | By Name(string name);
32 |
33 | [DispId(25), Description("Finds elements containing the given text.")]
34 | By PartialLinkText(string partialLinkText);
35 |
36 | [DispId(26), Description("Finds elements based on the HTML tag name")]
37 | By Tag(string tagName);
38 |
39 | [DispId(27), Description("Finds elements using an XPATH expression.")]
40 | By XPath(string xpath);
41 |
42 | [DispId(50), Description("Finds elements by using multiple strategies")]
43 | By Any([MarshalAs(UnmanagedType.Struct)]By by1
44 | , [MarshalAs(UnmanagedType.Struct)]By by2
45 | , [MarshalAs(UnmanagedType.Struct)]By by3 = null
46 | , [MarshalAs(UnmanagedType.Struct)]By by4 = null
47 | , [MarshalAs(UnmanagedType.Struct)]By by5 = null
48 | , [MarshalAs(UnmanagedType.Struct)]By by6 = null);
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Cookie.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-2276E80F5CF7")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Cookie {
11 |
12 | [DispId(30), Description("Gets the name of the cookie.")]
13 | string Name { get; }
14 |
15 | [DispId(32), Description("Gets the value of the cookie.")]
16 | string Value { get; }
17 |
18 | [DispId(34), Description("Gets the path of the cookie.")]
19 | string Path { get; }
20 |
21 | [DispId(36), Description("Gets the domain of the cookie.")]
22 | string Domain { get; }
23 |
24 | [DispId(38), Description("Gets a value indicating whether the cookie is secure.")]
25 | bool Secure { get; }
26 |
27 | [DispId(40), Description("Gets the expiration date of the cookie.")]
28 | string Expiry { get; }
29 |
30 | [DispId(245), Description("Deletes the specified cookie from the page.")]
31 | void Delete();
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Cookies.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-E6E7ED329824")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Cookies : System.Collections.IEnumerable {
11 |
12 | [DispId(0), Description("Get an item for a name or index (One-based)")]
13 | Cookie this[object identifier] { get; }
14 |
15 | [DispId(128), Description("Number of items")]
16 | int Count { get; }
17 |
18 | [DispId(-4)]
19 | System.Collections.IEnumerator _NewEnum(); //Has to be declared last
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Dictionary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-1456C48D8E5C")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
10 | public interface _Dictionary {
11 |
12 | [DispId(0), Description("Gets or sets the value associated with the specified key")]
13 | object this[string key] { get; set; }
14 |
15 | [DispId(128), Description("Gets the number of elements")]
16 | int Count { get; }
17 |
18 | [DispId(345), Description("Returns the value associated with the specified key or the default value if the key doesn't exist.")]
19 | object Get(string key, object defaultValue);
20 |
21 | [DispId(346), Description("Set the value for the given key")]
22 | void Set(string key, object value);
23 |
24 | [DispId(356), Description("Adds the specified key and value to the dictionary")]
25 | void Add(string key, object value);
26 |
27 | [DispId(367), Description("Removes all keys and values")]
28 | void Clear();
29 |
30 | [DispId(478), Description("Returms an array containing the keys")]
31 | string[] Keys();
32 |
33 | [DispId(489), Description("Returms an array containing the values")]
34 | object[] Values();
35 |
36 | [DispId(497), Description("Returns true if the dictionary has the key, false otherwise")]
37 | bool ContainsKey(string key);
38 |
39 | [DispId(550), Description("Copies the keys and values to the target range in Excel")]
40 | void ToExcel(object target = null, bool clear = false);
41 |
42 | [DispId(-4)]
43 | System.Collections.IEnumerator _NewEnum(); //Has to be declared last
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_DictionaryItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-A398E67A519B")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
10 | public interface _DictionaryItem {
11 |
12 | [DispId(50)]
13 | string Key { get; }
14 |
15 | [DispId(57)]
16 | object Value { get; }
17 |
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_IME.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | //TODO : Include IME
9 |
10 | [Guid("0277FC34-FD1B-4616-BB19-030859831269")]
11 | [ComVisible(false), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
12 | public interface _IME {
13 |
14 | [DispId(234), Description("Make an engines that is available (appears on the list returned by getAvailableEngines) active.")]
15 | void Activate(string engine);
16 |
17 | [DispId(236), Description("Get the name of the active IME engine.")]
18 | string ActiveEngine { get; }
19 |
20 | [DispId(238), Description("All available engines on the machine.")]
21 | List AvailableEngines { get; }
22 |
23 | [DispId(240), Description("De-activate IME input (turns off the currently activated engine).")]
24 | void Deactivate();
25 |
26 | [DispId(244), Description("Indicates whether IME input active at the moment (not if it's available).")]
27 | bool IsActivated { get; }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Image.cs:
--------------------------------------------------------------------------------
1 | using Interop.Excel;
2 | using Selenium.Internal;
3 | using System;
4 | using System.ComponentModel;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Selenium.ComInterfaces {
8 | #pragma warning disable 1591
9 |
10 | [Guid("0277FC34-FD1B-4616-BB19-54BA7C175990")]
11 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
12 | public interface _Image {
13 |
14 | [DispId(206), Description("Load an image file.")]
15 | Image Load(string filePath);
16 |
17 | [DispId(211), Description("Resize the image.")]
18 | Image Resize(float width = 0, float height = 0);
19 |
20 | [DispId(214), Description("Image width.")]
21 | short Width { get; }
22 |
23 | [DispId(218), Description("Image height.")]
24 | short Height { get; }
25 |
26 | [DispId(220), Description("Number of non matching pixels resulted from a comparison.")]
27 | int DiffCount { get; }
28 |
29 | [DispId(230), Description("Returns the image CRC32 hash value in hexa.")]
30 | string CRC { get; }
31 |
32 | [DispId(300), Description("Compare this image to another image(path or image) and return the result.")]
33 | Image CompareTo(object image, bool autoCenter = false, int offsetX = 0, int offsetY = 0, bool autoDispose = true);
34 |
35 | [DispId(320), Description("Copy the image to the clipboard.")]
36 | void Copy(bool autoDispose = true);
37 |
38 | [DispId(330), Description("Save the image to a file. Supported format: png, bmp, gif and jpg.")]
39 | string SaveAs(string filePath, bool autoDispose = true);
40 |
41 | [DispId(350), Description("Paste the image to excel and returns the range")]
42 | IRange ToExcel(object target = null, bool autoDispose = true);
43 |
44 | [DispId(389), Description("Returns a native StdPicture object")]
45 | Interop.IStdPicture GetPicture(bool autoDispose = true);
46 |
47 | [DispId(9999), Description("Dispose the image resources.")]
48 | void Dispose();
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Keyboard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-61DAD6C51012")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Keyboard {
11 |
12 | [DispId(728), Description("Returns a list of pressable keys.")]
13 | Keys Keys { get; }
14 |
15 | [DispId(730), Description("Sends a sequence of key strokes to the active element.")]
16 | Keyboard SendKeys(string keysOrModifiers, string keys = null);
17 |
18 | [DispId(732), Description("Presses and holds modifier keys (Control, Alt and Shift).")]
19 | Keyboard KeyDown(string modifiers);
20 |
21 | [DispId(734), Description("Release modifier keys (Control, Alt and Shift).")]
22 | Keyboard KeyUp(string modifiers);
23 |
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_List.cs:
--------------------------------------------------------------------------------
1 | using Interop.Excel;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-C539CB44B63F")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
11 | public interface _List {
12 |
13 | [DispId(0), Description("Gets or sets the value at index (One based)")]
14 | object this[int index] { get; set; }
15 |
16 | [DispId(1), Description("Set the value at index (One based)")]
17 | void Set(int index, object value);
18 |
19 | [DispId(2), Description("Get the value at index (One based)")]
20 | object Get(int index);
21 |
22 | [DispId(118), Description("Gets the number of elements")]
23 | int Count { get; }
24 |
25 | [DispId(345), Description("Returns the first element")]
26 | object First();
27 |
28 | [DispId(367), Description("Returns the last element")]
29 | object Last();
30 |
31 | [DispId(478), Description("Adds a value")]
32 | int Add(object value);
33 |
34 | [DispId(485), Description("Adds mutiple values at once")]
35 | void AddRange(object[] value);
36 |
37 | [DispId(487), Description("Remove item at index (One based)")]
38 | void RemoveAt(int index);
39 |
40 | [DispId(490), Description("Insert item at index (One based)")]
41 | void Insert(int index, object value);
42 |
43 | [DispId(492), Description("Remove item at index (One based)")]
44 | bool Contains(object value);
45 |
46 | [DispId(496), Description("Returns an array with the values")]
47 | object[] Values();
48 |
49 | [DispId(550), Description("Copy the values to the target address, range or worksheet in Excel. Returns the range.")]
50 | IRange ToExcel(object target = null, string title = null, bool clear = false);
51 |
52 | [DispId(600), Description("Sorts the elements.")]
53 | List Sort();
54 |
55 | [DispId(608), Description("Remove duplicates.")]
56 | List Distinct(bool ignoreCase = false);
57 |
58 | [DispId(-4)]
59 | System.Collections.IEnumerator _NewEnum(); //Has to be declared last
60 |
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Logs.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | //TODO : Include logs
10 |
11 | [Guid("0277FC34-FD1B-4616-BB19-F5671F493AAE")]
12 | [ComVisible(false), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
13 | public interface _Logs {
14 |
15 | [DispId(47), Description("Get the log entries for the browser")]
16 | List Browser { get; }
17 |
18 | [DispId(49), Description("Get the log entries for the client")]
19 | List Client { get; }
20 |
21 | [DispId(51), Description("Get the log entries for the driver")]
22 | List Driver { get; }
23 |
24 | [DispId(53), Description("Get the log entries for the server")]
25 | List Server { get; }
26 |
27 | [DispId(55), Description("Get available log types.")]
28 | List Types { get; }
29 |
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Manage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-11660D7615B7")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Manage {
11 |
12 | [DispId(43), Description("")]
13 | Storage StorageLocal { get; }
14 |
15 | [DispId(44), Description("")]
16 | Storage StorageSession { get; }
17 |
18 | [DispId(55), Description("Get the current geo location.")]
19 | Dictionary Location();
20 |
21 | [DispId(56), Description("Get the current geo location.")]
22 | void SetLocation(double latitude, double longitude, double altitude);
23 |
24 | [DispId(69), Description("Collection of cookies for the current page")]
25 | Cookies Cookies { get; }
26 |
27 | [DispId(72), Description("Adds a cookie to the current page.")]
28 | void AddCookie(string name, string value, string domain = null, string path = null, string expiry = null, bool secure = false, bool httpOnly = false);
29 |
30 | [DispId(75), Description("Deletes all cookies from the page.")]
31 | void DeleteAllCookies();
32 |
33 | [DispId(79), Description("Deletes the cookie with the specified name from the page.")]
34 | void DeleteCookieByName(string name);
35 |
36 | [DispId(82), Description("Gets a cookie with the specified name.")]
37 | Cookie FindCookieByName(string name);
38 |
39 | [DispId(101), Description("Get the session capabilities.")]
40 | Dictionary Capabilities { get; }
41 |
42 | //TODO : Include LOGS
43 | //[DispId(105), Description("")]
44 | //Logs Logs { get; }
45 |
46 | //TODO : Include IME
47 | //[DispId(132), Description("")]
48 | //IME IME { get; }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Mouse.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Selenium.ComInterfaces {
5 | #pragma warning disable 1591
6 |
7 | [Guid("0277FC34-FD1B-4616-BB19-63F894CA99E9")]
8 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
9 | public interface _Mouse {
10 |
11 | [DispId(231), Description("")]
12 | Mouse Click(MouseButton button = MouseButton.Left);
13 |
14 | [DispId(234), Description("")]
15 | Mouse ClickDouble();
16 |
17 | [DispId(237), Description("")]
18 | Mouse ClickAndHold(MouseButton button = MouseButton.Left);
19 |
20 | [DispId(239), Description("")]
21 | Mouse Release(MouseButton button = MouseButton.Left);
22 |
23 | [DispId(243), Description("")]
24 | Mouse MoveTo([MarshalAs(UnmanagedType.Struct)]WebElement element, int xoffset = 0, int yoffset = 0);
25 |
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_PdfFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-F2A56C3A68D4")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _PdfFile {
11 |
12 | [DispId(407), Description("Adds an image with borders to the Pdf")]
13 | void AddImage([MarshalAs(UnmanagedType.Struct)]Image image, bool autoDispose = true);
14 |
15 | [DispId(412), Description("Adds a new page")]
16 | void AddPage();
17 |
18 | [DispId(416), Description("Adds a bookmark for the current position")]
19 | void AddBookmark(string name);
20 |
21 | [DispId(420), Description("Adds a vertical space")]
22 | void AddSpace(int size);
23 |
24 | [DispId(432), Description("Adds a clickable link")]
25 | void AddLink(string link, string text = null, int size = 10);
26 |
27 | [DispId(437), Description("Adds a text to the Pdf")]
28 | void AddText(string text, short size = 10, bool bold = false, bool italic = false, string color = null);
29 |
30 | [DispId(440), Description("Adds a centered text to the Pdf")]
31 | void AddTextCenter(string text, short size = 10, bool bold = false, bool italic = false, string color = null);
32 |
33 | [DispId(460), Description("Adds a title")]
34 | void AddTitle(string text, short size = 11, bool bold = true, bool italic = false);
35 |
36 | [DispId(465), Description("Saves the pdf")]
37 | void SaveAs(string filepath);
38 |
39 | [DispId(470), Description("Set the page margins (inch by default)")]
40 | void SetMargins(int left, int right, int top, int bottom, string metric = "in");
41 |
42 | [DispId(478), Description("Set the page size (inch by default)")]
43 | void SetPageSize(int width, int heigth, string metric = "in");
44 |
45 | [DispId(9999), Description("Releases the resources")]
46 | void Dispose();
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Point.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-ACE280CD7780")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Point {
11 |
12 | [DispId(43), Description("X")]
13 | int X { get; }
14 |
15 | [DispId(45), Description("Y")]
16 | int Y { get; }
17 |
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Proxy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-D0E30A5D0697")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Proxy {
11 |
12 | [DispId(615), Description("")]
13 | void SetAutoConfigure(string url);
14 |
15 | [DispId(617), Description("")]
16 | void SetAutodetect();
17 |
18 | [DispId(620), Description("")]
19 | void SetFTPProxy(string value);
20 |
21 | [DispId(622), Description("")]
22 | void SetHttpProxy(string value);
23 |
24 | [DispId(625), Description("")]
25 | void SetSocksProxy(string value, string username = null, string password = null);
26 |
27 | [DispId(628), Description("")]
28 | void SetSSLProxy(string value);
29 |
30 | [DispId(-4)]
31 | System.Collections.IEnumerator _NewEnum(); //Has to be declared last
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_SelectElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-4CE442A16502")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _SelectElement {
11 |
12 | [DispId(401), Description("")]
13 | bool IsMultiple { get; }
14 |
15 | [DispId(404), Description("Returns a list of all options belonging to this select tag")]
16 | WebElements Options { get; }
17 |
18 | [DispId(408), Description("The first selected option in this select tag (or the currently selected option in a normal select)")]
19 | WebElement SelectedOption { get; }
20 |
21 | [DispId(411), Description("Gets all of the selected options within the select element.")]
22 | WebElements AllSelectedOptions { get; }
23 |
24 | [DispId(413), Description("Select the option at the given index. This is done by examing the “index” attribute of an element, and not merely by counting.")]
25 | void SelectByIndex(int index);
26 |
27 | [DispId(416), Description("Select all options that display text matching the argument.")]
28 | void SelectByText(string text);
29 |
30 | [DispId(418), Description("Select all options that have a value matching the argument.")]
31 | void SelectByValue(string value);
32 |
33 | [DispId(421), Description("Clear all selected entries. This is only valid when the SELECT supports multiple selections. throws NotImplementedError If the SELECT does not support multiple selections")]
34 | void DeselectAll();
35 |
36 | [DispId(423), Description("Deselect the option at the given index. This is done by examing the “index” attribute of an element, and not merely by counting.")]
37 | void DeselectByIndex(int index);
38 |
39 | [DispId(425), Description("Deselect all options that display text matching the argument.")]
40 | void DeselectByText(string text);
41 |
42 | [DispId(427), Description("Deselect all options that have a value matching the argument. That is, when given “foo” this would deselect an option like:")]
43 | void DeselectByValue(string value);
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Size.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-7E2EBB6C82E9")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Size {
11 |
12 | [DispId(43), Description("Width")]
13 | int Width { get; }
14 |
15 | [DispId(45), Description("Height")]
16 | int Height { get; }
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Storage.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-C6F450B6EE52")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
11 | public interface _Storage {
12 |
13 | [DispId(0), Description("Get or set the storage item for the given key.")]
14 | string this[string key] { get; set; }
15 |
16 | [DispId(128), Description("Get the number of items in the storage.")]
17 | int Count();
18 |
19 | [DispId(705), Description("Get all keys of the storage.")]
20 | List Keys();
21 |
22 | [DispId(709), Description("Clear the storage.")]
23 | void Clear();
24 |
25 | [DispId(713), Description("Remove the storage item for the given key.")]
26 | void Remove(string key);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Table.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-B825A6BF9610")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
11 | public interface _Table : IEnumerable {
12 |
13 | [DispId(0), Description("Gets the row at the the given index (One based)")]
14 | object this[int index] { get; }
15 |
16 | [DispId(128), Description("Returns the number of rows")]
17 | int Count { get; }
18 |
19 | [DispId(8253), Description("Loads the data from an Excel source (address, range or worksheet)")]
20 | Table From(object sourceExcel, bool hasHeaders = true);
21 |
22 | [DispId(8346), Description("Filter the rows using the given expression")]
23 | Table Where(string expression, string sortBy = null);
24 |
25 | [DispId(9076), Description("Returns the values in a 2dim array")]
26 | object[,] Values();
27 |
28 | [DispId(550), Description("Copy the data to the target (Address, Range or Worksheet).")]
29 | void ToExcel(object target = null, bool clear = false);
30 |
31 | [DispId(9999)]
32 | void Dispose();
33 |
34 | [DispId(-4)]
35 | System.Collections.IEnumerator _NewEnum(); //Has to be declared last
36 |
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_TableElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-BE15C121F199")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _TableElement {
11 |
12 | [DispId(810), Description("Return an array filled with data from a table element")]
13 | object[,] Data(int firstRowsToSkip = 0, int lastRowsToSkip = 0, string map = null);
14 |
15 | [DispId(812), Description("Copy the data to the target (Address, Range or Worksheet).")]
16 | void ToExcel(object target = null, bool clear = false, int firstRowsToSkip = 0, int lastRowsToSkip = 0, string map = null);
17 |
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_TableRow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-0B61E370369D")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
11 | public interface _TableRow {
12 |
13 | [DispId(0), IndexerName("Column"), Description("Gets or sets the value associated with the column identifier")]
14 | object this[[MarshalAs(UnmanagedType.Struct), In] object identifier] { get; set; }
15 |
16 | [DispId(1), Description("Gets thevalue associated with the column identifier")]
17 | object Get(object identifier);
18 |
19 | [DispId(2), Description("Sets the value associated with the column identifier")]
20 | void Set(object identifier, object value);
21 |
22 | [DispId(346), Description("Gets the cell asscociated with the column identifier")]
23 | object Cell(object identifier);
24 |
25 | [DispId(378), Description("Gets an array containing all the values of the row")]
26 | object Values { get; }
27 |
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Timeouts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-74F5D5680428")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Timeouts {
11 |
12 | [DispId(476), Description("Amount of time that Selenium will wait for waiting commands to complete")]
13 | int ImplicitWait { get; set; }
14 |
15 | [DispId(459), Description("Amount of time the driver should wait while loading a page before throwing an exception.")]
16 | int PageLoad { get; set; }
17 |
18 | [DispId(465), Description("Amount of time the driver should wait while executing a script before throwing an exception.")]
19 | int Script { get; set; }
20 |
21 | [DispId(489), Description("Maximum amount of time the driver should wait while waiting for a response from the server.")]
22 | int Server { get; set; }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_TouchActions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-D5DE929CF018")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _TouchActions {
11 |
12 | [DispId(6112), Description("")]
13 | TouchActions Wait(int timems);
14 |
15 | [DispId(6117), Description("")]
16 |
17 | TouchActions Tap([MarshalAs(UnmanagedType.Struct)]WebElement element);
18 |
19 | [DispId(6121), Description("")]
20 | TouchActions TapDouble([MarshalAs(UnmanagedType.Struct)]WebElement element);
21 |
22 | [DispId(6125), Description("")]
23 | TouchActions PressHold(int locationX, int locationY);
24 |
25 | [DispId(6129), Description("")]
26 | TouchActions PressRelease(int locationX, int locationY);
27 |
28 | [DispId(6131), Description("")]
29 | TouchActions TapLong([MarshalAs(UnmanagedType.Struct)]WebElement element);
30 |
31 | [DispId(6137), Description("")]
32 | TouchActions Flick(int speedX, int speedY);
33 |
34 | [DispId(6143), Description("")]
35 | TouchActions FlickFrom([MarshalAs(UnmanagedType.Struct)]WebElement element, int offsetX, int offsetY, int speed);
36 |
37 | [DispId(6148), Description("")]
38 | TouchActions Move(int locationX, int locationY);
39 |
40 | [DispId(6153), Description("")]
41 | TouchActions Scroll(int offsetX, int offsetY);
42 |
43 | [DispId(6159), Description("")]
44 | TouchActions ScrollFrom([MarshalAs(UnmanagedType.Struct)]WebElement element, int offsetX, int offsetY);
45 |
46 | [DispId(6165), Description("Performs all stored Actions.")]
47 | void Perform();
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_TouchScreen.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Selenium.ComInterfaces {
5 | #pragma warning disable 1591
6 |
7 | [Guid("0277FC34-FD1B-4616-BB19-FFD6FAEF290A")]
8 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
9 | public interface _TouchScreen {
10 |
11 | [DispId(3423), Description("")]
12 | bool IsPortrait();
13 |
14 | [DispId(3427), Description("")]
15 | void ToLandscape();
16 |
17 | [DispId(3429), Description("")]
18 | void ToPortrait();
19 |
20 | [DispId(3432), Description("")]
21 | TouchScreen FlickFrom([MarshalAs(UnmanagedType.Struct)]WebElement element, int xoffset, int yoffset, int speed);
22 |
23 | [DispId(3435), Description("")]
24 | TouchScreen Flick(int xspeed, int yspeed);
25 |
26 | [DispId(3438), Description("")]
27 | TouchScreen Move(int x, int y);
28 |
29 | [DispId(3442), Description("")]
30 | TouchScreen PressHold(int x, int y);
31 |
32 | [DispId(3445), Description("")]
33 | TouchScreen PressRelease(int x, int y);
34 |
35 | [DispId(3447), Description("")]
36 | TouchScreen ScrollFrom([MarshalAs(UnmanagedType.Struct)]WebElement element, int xoffset, int yoffset);
37 |
38 | [DispId(3449), Description("")]
39 | TouchScreen Scroll(int xoffset, int yoffset);
40 |
41 | [DispId(3453), Description("")]
42 | TouchScreen Tap([MarshalAs(UnmanagedType.Struct)]WebElement element);
43 |
44 | [DispId(3459), Description("")]
45 | TouchScreen TapDouble([MarshalAs(UnmanagedType.Struct)]WebElement element);
46 |
47 | [DispId(3465), Description("")]
48 | TouchScreen TapLong([MarshalAs(UnmanagedType.Struct)]WebElement element);
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Utils.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-01D514FE0B1A")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
11 | [Description("")]
12 | public interface _Utils {
13 |
14 | [DispId(265), Description("Get a screenshot of the desktop")]
15 | Image TakeScreenShot();
16 |
17 | [DispId(403), Description("Sends keystrokes to the active application using the windows SendKeys methode.")]
18 | void SendKeysNat(string keys);
19 |
20 | [DispId(407), Description("Indicates whether the regular expression finds a match in the input string using the regular expression specified in the pattern parameter.")]
21 | bool IsMatch(string input, string pattern);
22 |
23 | [DispId(410), Description("Searches the specified input string for an occurrence of the regular expression supplied in the pattern parameter.")]
24 | string Match(string input, string pattern, short group = 0);
25 |
26 | [DispId(413), Description("Searches the specified input string for all the occurrences of the regular expression supplied in the pattern parameter.")]
27 | List Matches(string input, string pattern, short group = 0);
28 |
29 | [DispId(423), Description("Searches the specified input string for an occurrence of the regular expression supplied in the pattern parameter and replace it.")]
30 | string Replace(string input, string pattern, string replacement);
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Verify.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-495CC9DBFB96")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Verify {
11 |
12 | [DispId(564), Description("Returns if the value is true, otherwise.")]
13 | string True(bool value, string failmessage = null);
14 |
15 | [DispId(567), Description("Returns if the value is false, otherwise.")]
16 | string False(bool value, string failmessage = null);
17 |
18 | [DispId(574), Description("Returns if the objects are equal, otherwise.")]
19 | string Equals(object expected, object input, string failmessage = null);
20 |
21 | [DispId(579), Description("Returns if the objects are not equal, otherwise.")]
22 | string NotEquals(object expected, object input, string failmessage = null);
23 |
24 | [DispId(583), Description("Returns if the text matches the pattern, otherwise.")]
25 | string Matches(string pattern, string input, string failmessage = null);
26 |
27 | [DispId(587), Description("Returns if the text does not match the pattern, otherwise.")]
28 | string NotMatches(string pattern, string input, string failmessage = null);
29 |
30 | [DispId(589), Description("Returns if the text contains the value, otherwise.")]
31 | string Contains(string value, string input, string failmessage = null);
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Waiter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.ComInterfaces {
6 | #pragma warning disable 1591
7 |
8 | [Guid("0277FC34-FD1B-4616-BB19-384C7E50EFA8")]
9 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
10 | public interface _Waiter {
11 |
12 | [DispId(567), Description("Returns a boolean to continue looping and throws an exception if the timeout(ms) is reached.")]
13 | bool Not(object result, int timeout = -1, string timeoutMessage = null);
14 |
15 | [DispId(789), Description("Set the waiter timeout. Default is 30000 milliseconds")]
16 | int Timeout { get; set; }
17 |
18 | [DispId(798), Description("Waits the given time in milliseconds")]
19 | void Wait(int timems);
20 |
21 | [DispId(830), Description("Waits for the given function to return true. Ex: Waiter.Until addressOf MyFunction")]
22 | object Until(object function, object argument = null, int timeout = -1, string timeoutMessage = null);
23 |
24 | [DispId(876), Description("Waits for a file to be ready.")]
25 | void WaitForFile(string path, int timeout = -1);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_WebElements.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-7C9763568492")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
11 | public interface _WebElements : System.Collections.IEnumerable {
12 |
13 | [DispId(0), Description("Get the WebElement at the provided index (One-based)")]
14 | WebElement this[int index] { get; }
15 |
16 | [DispId(118), Description("Number of web elements")]
17 | int Count { get; }
18 |
19 | [DispId(345), Description("Returns the first element")]
20 | WebElement First();
21 |
22 | [DispId(367), Description("Returns the last element")]
23 | WebElement Last();
24 |
25 | [DispId(67), Description("Return and array containing the attribute for each web element")]
26 | List Attribute(string attributeName, bool withAttributeOnly = true);
27 |
28 | [DispId(601), Description("Executes a script for each element and returns the results. Ex: return element.tagName;")]
29 | List ExecuteScript(string script, bool includeNullResults = false);
30 |
31 | [DispId(602), Description("Execute an asynchronous piece of JavaScript and returns the results.")]
32 | List ExecuteAsyncScript(string script, int timeout = -1);
33 |
34 | [DispId(86), Description("Returns a list containing the text for each element")]
35 | List Text(int offsetStart = 0, int offsetEnd = 0, bool trim = true);
36 |
37 | [DispId(92), Description("Returns a list containing the text parsed to a number for each element")]
38 | List Values(object defaultValue = null, int offsetStart = 0, int offsetEnd = 0);
39 |
40 | [DispId(-4)]
41 | System.Collections.IEnumerator _NewEnum(); //Has to be declared last
42 |
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Selenium/ComInterfaces/_Window.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.ComInterfaces {
7 | #pragma warning disable 1591
8 |
9 | [Guid("0277FC34-FD1B-4616-BB19-FBDA3A91C82B")]
10 | [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
11 | public interface _Window {
12 |
13 | [DispId(500), Description("Set the context to this window.")]
14 | Window Activate();
15 |
16 | [DispId(533), Description("Gets the size of the outer browser window")]
17 | Size Size();
18 |
19 | [DispId(536), Description("Switch to the window with the provided name")]
20 | Window SwitchToWindowByName(string name, int timeout = -1);
21 |
22 | [DispId(537), Description("Switch to the window with the provided title")]
23 | Window SwitchToWindowByTitle(string title, int timeout = -1);
24 |
25 | [DispId(538), Description("Switch to the next window")]
26 | Window SwitchToNextWindow(int timeout = -1);
27 |
28 | [DispId(540), Description("Switch to the previous window")]
29 | Window SwitchToPreviousWindow();
30 |
31 | [DispId(544), Description("Sets the size of the outer browser window, including title bars and window borders.")]
32 | void SetSize(int width, int height);
33 |
34 | [DispId(550), Description("Get the title of the window")]
35 | string Title { get; }
36 |
37 | [DispId(554), Description("Gets the position of the browser window relative to the upper-left corner of the screen.")]
38 | Point Position();
39 |
40 | [DispId(557), Description("Sets the position of the browser window relative to the upper-left corner of the screen.")]
41 | void SetPosition(int x, int y);
42 |
43 | [DispId(562), Description("Maximizes the current window if it is not already maximized")]
44 | void Maximize();
45 |
46 | [DispId(567), Description("Set the current window full screen")]
47 | void FullScreen();
48 |
49 | [DispId(574), Description("Closes the current window")]
50 | void Close();
51 |
52 | [DispId(899), Description("Evaluate equality")]
53 | bool Equals(object obj);
54 |
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/Selenium/Common/CacheState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Selenium {
5 |
6 | ///
7 | /// Cache status
8 | ///
9 | [Guid("0277FC34-FD1B-4616-BB19-C724C5135B6E")]
10 | [ComVisible(true)]
11 | public enum CacheState {
12 | ///
13 | UNCACHED = 0,
14 | ///
15 | IDLE = 1,
16 | ///
17 | CHECKING = 2,
18 | ///
19 | DOWNLOADING = 3,
20 | ///
21 | UPDATE_READY = 4,
22 | ///
23 | OBSOLETE = 5
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Selenium/Common/IME.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using System.ComponentModel;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium {
6 |
7 | //TODO : Include IME
8 |
9 | ///
10 | /// Input method engine object
11 | ///
12 | [ProgId("Selenium.IME")]
13 | [Guid("0277FC34-FD1B-4616-BB19-C8F963D978AA")]
14 | [Description("Input method engine.")]
15 | [ComVisible(false), ClassInterface(ClassInterfaceType.None)]
16 | public class IME : ComInterfaces._IME {
17 |
18 | private Session _session;
19 |
20 | internal IME(Session session) {
21 | _session = session;
22 | }
23 |
24 | ///
25 | /// List all available engines on the machine.
26 | ///
27 | /// A list of available engines
28 | public List AvailableEngines {
29 | get {
30 | return (List)_session.Send(RequestMethod.GET, "/ime/available_engines");
31 | }
32 | }
33 |
34 | ///
35 | /// Get the name of the active IME engine.
36 | ///
37 | /// The name of the active IME engine.
38 | public string ActiveEngine {
39 | get {
40 | return (string)_session.Send(RequestMethod.GET, "/ime/active_engine");
41 | }
42 | }
43 |
44 | ///
45 | /// Indicates whether IME input is active at the moment.
46 | ///
47 | /// true if IME input is available and currently active, false otherwise
48 | public bool IsActivated {
49 | get {
50 | return (bool)_session.Send(RequestMethod.GET, "/ime/activated");
51 | }
52 | }
53 |
54 | ///
55 | /// De-activates the currently-active IME engine.
56 | ///
57 | public void Deactivate() {
58 | _session.Send(RequestMethod.POST, "/ime/deactivate");
59 | }
60 |
61 | ///
62 | /// Make an engines that is available (appears on the listreturned by getAvailableEngines) active.
63 | ///
64 | /// Name of the engine to activate.
65 | public void Activate(string engine) {
66 | _session.Send(RequestMethod.POST, "/ime/activate", "engine", engine);
67 | }
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/Selenium/Common/Logs.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using Selenium;
3 | using System.ComponentModel;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium {
7 |
8 | //TODO : Include logs
9 |
10 | ///
11 | /// Logs object
12 | ///
13 | [ProgId("Selenium.Logs")]
14 | [Guid("0277FC34-FD1B-4616-BB19-E9C0E4941F8F")]
15 | [Description("Logs object")]
16 | [ComVisible(false), ClassInterface(ClassInterfaceType.None)]
17 | public class Logs : ComInterfaces._Logs {
18 |
19 | const string BASE_URI = "/log";
20 |
21 | private RemoteSession _session;
22 |
23 | internal Logs(RemoteSession session) {
24 | _session = session;
25 | }
26 |
27 | ///
28 | /// Get the log entries for the server
29 | ///
30 | /// The list of log entries.
31 | public List Server {
32 | get {
33 | return (List)_session.Send(RequestMethod.POST, BASE_URI, "type", "server");
34 | }
35 | }
36 |
37 | ///
38 | /// Get the log entries for the browser
39 | ///
40 | /// The list of log entries.
41 | public List Browser {
42 | get {
43 | return (List)_session.Send(RequestMethod.POST, BASE_URI, "type", "browser");
44 | }
45 | }
46 |
47 | ///
48 | /// Get the log entries for the client
49 | ///
50 | /// The list of log entries.
51 | public List Client {
52 | get {
53 | return (List)_session.Send(RequestMethod.POST, BASE_URI, "type", "client");
54 | }
55 | }
56 |
57 | ///
58 | /// Get the log entries for the driver
59 | ///
60 | /// The list of log entries.
61 | public List Driver {
62 | get {
63 | return (List)_session.Send(RequestMethod.POST, BASE_URI, "type", "driver");
64 | }
65 | }
66 |
67 | ///
68 | /// Get available log types.
69 | ///
70 | /// The list of available log types.
71 | public List Types {
72 | get {
73 | return (List)_session.Send(RequestMethod.GET, BASE_URI + "/types");
74 | }
75 | }
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Selenium/Common/MouseButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Selenium {
5 |
6 | ///
7 | /// Mouse buttons
8 | ///
9 | [Guid("0277FC34-FD1B-4616-BB19-B342CE81CB2A")]
10 | [ComVisible(true)]
11 | public enum MouseButton : short {
12 | ///
13 | Left = 0,
14 | ///
15 | Middle = 1,
16 | ///
17 | Right = 2
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Selenium/Common/Strategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Selenium {
5 |
6 | ///
7 | /// Mechanism by which to find elements within a document.
8 | ///
9 | [Guid("0277FC34-FD1B-4616-BB19-300DAA508541")]
10 | [ComVisible(true)]
11 | public enum Strategy : short {
12 | ///
13 | None = 0,
14 | ///
15 | Class = 1,
16 | ///
17 | Css = 2,
18 | ///
19 | Id = 3,
20 | ///
21 | Name = 4,
22 | ///
23 | LinkText = 5,
24 | ///
25 | PartialLinkText = 6,
26 | ///
27 | Tag = 7,
28 | ///
29 | XPath = 8,
30 | ///
31 | Any = 9
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/Selenium/Core/DeserializeException.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 | using System;
3 |
4 | namespace Selenium.Core {
5 |
6 | ///
7 | /// Exception occuring when a Json object is not recognized.
8 | ///
9 | class DeserializeException : SeleniumException {
10 |
11 | internal DeserializeException(Type type, Errors.KeyNotFoundError ex)
12 | : base("Failed to deserialize the {0} object. Missing key: {1}", type.Name, ex.Key) { }
13 |
14 | internal DeserializeException(Type type, InvalidCastException ex)
15 | : base("Failed to deserialize the {0} object. Invalid type of value.", type.Name) { }
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Selenium/Core/DriverExtension.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Serializer;
2 | using System.IO;
3 |
4 | namespace Selenium.Core {
5 |
6 | class DriverExtension : IJsonBinary {
7 |
8 | private string _path;
9 |
10 | public DriverExtension(string path) {
11 | _path = path;
12 | }
13 |
14 | public string Path {
15 | get {
16 | return _path;
17 | }
18 | }
19 |
20 | public void Save(Stream stream) {
21 | byte[] buffer = new byte[1024 * 64];
22 | int read = buffer.Length;
23 | using (var file = File.Open(_path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
24 | while ((read = file.Read(buffer, 0, read)) > 0)
25 | stream.Write(buffer, 0, read);
26 | }
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/Selenium/Core/FrameContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Selenium.Core {
4 |
5 | ///
6 | /// Context manager
7 | ///
8 | class FrameContext {
9 |
10 | private RemoteSession _session;
11 |
12 | ///
13 | /// Contructor over a session
14 | ///
15 | ///
16 | internal FrameContext(RemoteSession session) {
17 | _session = session;
18 | }
19 |
20 | ///
21 | /// Switches focus to the specified frame, by index, name or WebElement.
22 | ///
23 | /// The name, id, or WebElement of the frame to switch.
24 | /// Optional timeout in milliseconds
25 | public void SwitchToFrame(object identifier, int timeout) {
26 | if (identifier == null)
27 | throw new Errors.ArgumentError("Invalid type for argument identifier");
28 |
29 | var element = identifier as WebElement;
30 | if (element != null) {
31 | identifier = element.SerializeJson();
32 | }
33 |
34 | try {
35 | _session.Send(RequestMethod.POST, "/frame", "id", identifier);
36 | } catch (Errors.NoSuchFrameError) {
37 | if (timeout == 0)
38 | throw;
39 | var endTime = _session.GetEndTime(timeout);
40 | while (true) {
41 | SysWaiter.Wait();
42 | try {
43 | _session.SendAgain();
44 | break;
45 | } catch (Errors.NoSuchFrameError) {
46 | if (DateTime.UtcNow > endTime)
47 | throw;
48 | }
49 | }
50 | }
51 | }
52 |
53 | ///
54 | /// Select the parent frame of the currently selected frame.
55 | ///
56 | public void SwitchToParentFrame() {
57 | _session.Send(RequestMethod.POST, "/frame/parent");
58 | }
59 |
60 | ///
61 | /// Selects either the first frame on the page or the main document when a page contains iFrames.
62 | ///
63 | public void SwitchToDefaultContent() {
64 | _session.Send(RequestMethod.POST, "/frame", "id", null);
65 | }
66 |
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/Selenium/Core/IDriverService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 |
4 | namespace Selenium.Core {
5 |
6 | interface IDriverService {
7 |
8 | IPEndPoint IPEndPoint { get; }
9 |
10 | string Uri { get; }
11 |
12 | void Quit(RemoteServer server);
13 |
14 | void Dispose();
15 |
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Selenium/Core/RequestMethod.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Selenium.Core {
4 |
5 | enum RequestMethod {
6 | POST,
7 | GET,
8 | DELETE
9 | };
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Selenium/Drivers/EdgeDriver.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using Selenium.Core;
3 | using System;
4 | using System.Net;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace Selenium {
9 |
10 | ///
11 | /// Web driver for Microsoft Edge driver
12 | ///
13 | ///
14 | ///
15 | ///
16 | /// VBScript:
17 | ///
18 | /// Class Script
19 | /// Dim driver
20 | ///
21 | /// Sub Class_Initialize
22 | /// Set driver = CreateObject("Selenium.EdgeDriver")
23 | /// driver.Get "http://www.google.com"
24 | /// ...
25 | /// End Sub
26 | ///
27 | /// Sub Class_Terminate
28 | /// driver.Quit
29 | /// End Sub
30 | /// End Class
31 | ///
32 | /// Set s = New Script
33 | ///
34 | ///
35 | /// VBA:
36 | ///
37 | /// Public Sub Script()
38 | /// Dim driver As New EdgeDriver
39 | /// driver.Get "http://www.mywebsite.com"
40 | /// ...
41 | /// driver.Quit
42 | /// End Sub
43 | ///
44 | ///
45 | ///
46 | [ProgId("Selenium.EdgeDriver")]
47 | [Guid("0277FC34-FD1B-4616-BB19-3C406728F1A2")]
48 | [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
49 | public class EdgeDriver : WebDriver, ComInterfaces._WebDriver {
50 |
51 | const string BROWSER_NAME = "MicrosoftEdge";
52 |
53 | ///
54 | ///
55 | ///
56 | public EdgeDriver()
57 | : base(BROWSER_NAME) { }
58 |
59 | internal static IDriverService StartService(WebDriver wd) {
60 | ExtendCapabilities(wd, false);
61 |
62 | var svc = new DriverService();
63 | svc.AddArgument("--host=localhost");
64 | svc.AddArgument("--port=" + svc.IPEndPoint.Port.ToString());
65 | svc.Start("edgedriver.exe", true);
66 | return svc;
67 | }
68 |
69 | internal static void ExtendCapabilities(WebDriver wd, bool remote) {
70 | Capabilities capa = wd.Capabilities;
71 |
72 | Dictionary opts;
73 | if (!capa.TryGetValue("edgeOptions", out opts))
74 | capa["edgeOptions"] = opts = new Dictionary();
75 |
76 | }
77 |
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/Selenium/Drivers/FirefoxDriver.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using System;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium {
6 |
7 | ///
8 | /// Web driver for Firefox
9 | ///
10 | ///
11 | ///
12 | ///
13 | /// VBScript:
14 | ///
15 | /// Class Script
16 | /// Dim driver
17 | ///
18 | /// Sub Class_Initialize
19 | /// Set driver = CreateObject("Selenium.FirefoxDriver")
20 | /// driver.Get "http://www.google.com"
21 | /// End Sub
22 | ///
23 | /// Sub Class_Terminate
24 | /// driver.Quit
25 | /// ...
26 | /// End Sub
27 | /// End Class
28 | ///
29 | /// Set s = New Script
30 | ///
31 | ///
32 | /// VBA:
33 | ///
34 | /// Public Sub Script()
35 | /// Dim driver As New FirefoxDriver
36 | /// driver.Get "http://www.mywebsite.com"
37 | /// ...
38 | /// driver.Quit
39 | /// End Sub
40 | ///
41 | ///
42 | ///
43 | [ProgId("Selenium.FirefoxDriver")]
44 | [Guid("0277FC34-FD1B-4616-BB19-14DB1E4916D4")]
45 | [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
46 | public class FirefoxDriver : WebDriver, ComInterfaces._WebDriver {
47 |
48 | const string BROWSER_NAME = "firefox";
49 |
50 | public FirefoxDriver()
51 | : base(BROWSER_NAME) { }
52 |
53 | internal static IDriverService StartService(WebDriver wd) {
54 | ExtendCapabilities(wd, false);
55 |
56 | FirefoxService svc = new FirefoxService();
57 | svc.Start(wd.Arguments, wd.Preferences, wd.Extensions, wd.Capabilities, wd.Profile, wd.Persistant);
58 | return svc;
59 | }
60 |
61 | internal static void ExtendCapabilities(WebDriver wd, bool remote) {
62 | var capa = wd.Capabilities;
63 | capa["webdriver.logging.profiler.enabled"] = false;
64 | capa["loggingPrefs"] = new Dictionary {
65 | {"profiler", "OFF"},
66 | {"driver", "OFF"},
67 | {"browser", "OFF"}
68 | };
69 |
70 | if (wd.Binary != null)
71 | capa["firefox_binary"] = wd.Binary;
72 | }
73 |
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/Selenium/Drivers/PhantomJSDriver.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using System;
3 | using System.Net;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium {
7 |
8 | ///
9 | /// Web driver for PhantomJS (Headless browser)
10 | ///
11 | ///
12 | ///
13 | /// VBScript:
14 | ///
15 | /// Class Script
16 | /// Dim driver
17 | ///
18 | /// Sub Class_Initialize
19 | /// Set driver = CreateObject("Selenium.PhantomJSDriver")
20 | /// driver.Get "http://www.google.com"
21 | /// End Sub
22 | ///
23 | /// Sub Class_Terminate
24 | /// driver.Quit
25 | /// End Sub
26 | /// End Class
27 | ///
28 | /// Set s = New Script
29 | ///
30 | ///
31 | /// VBA:
32 | ///
33 | /// Public Sub Script()
34 | /// Dim driver As New PhantomJSDriver
35 | /// driver.Get "http://www.google.com"
36 | /// ...
37 | /// driver.Quit
38 | /// End Sub
39 | ///
40 | ///
41 | ///
42 | [ProgId("Selenium.PhantomJSDriver")]
43 | [Guid("0277FC34-FD1B-4616-BB19-0809389E78C4")]
44 | [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
45 | public class PhantomJSDriver : WebDriver, ComInterfaces._WebDriver {
46 |
47 | const string BROWSER_NAME = "phantomjs";
48 |
49 | public PhantomJSDriver()
50 | : base(BROWSER_NAME) { }
51 |
52 | internal static IDriverService StartService(WebDriver wd) {
53 | ExtendCapabilities(wd, false);
54 |
55 | var svc = new DriverService();
56 | svc.AddArgument("--webdriver=" + svc.IPEndPoint.ToString());
57 | svc.AddArgument("--webdriver-loglevel=ERROR");
58 | svc.AddArgument("--ignore-ssl-errors=true");
59 | svc.Start("phantomjs.exe");
60 | return svc;
61 | }
62 |
63 | internal static void ExtendCapabilities(WebDriver wd, bool remote) {
64 | var capa = wd.Capabilities;
65 | capa.BrowserName = "phantomjs";
66 | if (wd.Arguments.Count > 0)
67 | capa["phantomjs.cli.args"] = wd.Arguments;
68 | }
69 |
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/Selenium/Errors/ArgumentErrors.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Selenium.Errors {
4 |
5 | ///
6 | ///
7 | ///
8 | public class ArgumentError : SeleniumError {
9 |
10 | const int CODE = 200;
11 |
12 | internal ArgumentError(string message, params object[] args)
13 | : this(CODE, message, args) { }
14 |
15 | internal ArgumentError(int code, string message, params object[] args)
16 | : base(CODE + code, message, args) { }
17 |
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | public class ArgumentTypeError : ArgumentError {
24 | internal ArgumentTypeError(Type extected, Type got)
25 | : base(1, "Invalid type. Was expecting a {0}, got a {1} intead", extected.Name, got.Name) { }
26 | }
27 |
28 | ///
29 | ///
30 | ///
31 | public class ArgumentRangeError : ArgumentError {
32 | internal ArgumentRangeError(string arg)
33 | : base(2, "Argument out of range: {0}", arg) {
34 | }
35 | }
36 |
37 | ///
38 | ///
39 | ///
40 | public class InvalideCommandError : ArgumentError {
41 | internal InvalideCommandError(string message)
42 | : base(3, message) { }
43 | }
44 |
45 | ///
46 | ///
47 | ///
48 | public class InvalideModifierKeyError : ArgumentError {
49 | internal InvalideModifierKeyError()
50 | : base(56, "Invalid modifier key.\nOnly shift, ctrl or alt are allowed.") { }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/Selenium/Errors/DictionaryErrors.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Errors {
3 |
4 | ///
5 | /// Exception occurring when a key is missing in the dictionary
6 | ///
7 | public class KeyNotFoundError : SeleniumError {
8 |
9 | ///
10 | /// Missing key
11 | ///
12 | public readonly string Key;
13 |
14 | internal KeyNotFoundError(string key)
15 | : base("Dictionary key not found: " + key) {
16 | Key = key;
17 | }
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/Selenium/Errors/FileNotFoundError.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Errors {
3 |
4 | ///
5 | /// File not found error
6 | ///
7 | class FileNotFoundError : SeleniumError {
8 | internal FileNotFoundError(string filepath)
9 | : base("File: " + filepath) { }
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Selenium/Errors/ImageErrors.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Errors {
3 |
4 | ///
5 | /// NullImageError
6 | ///
7 | public class ImageError : SeleniumError {
8 | internal ImageError(string message)
9 | : base(message) { }
10 | }
11 |
12 | ///
13 | /// NullImageError
14 | ///
15 | public class NullImageError : ImageError {
16 | internal NullImageError()
17 | : base("Image has been disposed.") { }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Selenium/Errors/InvalidOperationError.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Errors {
3 |
4 | ///
5 | ///
6 | ///
7 | public class InvalidOperationError : SeleniumError {
8 | internal InvalidOperationError(string message, params object[] args)
9 | : base(50, message, args) { }
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Selenium/Errors/KeyboardInterruptError.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Selenium.Errors {
4 |
5 | ///
6 | ///
7 | ///
8 | public class KeyboardInterruptError : SeleniumError {
9 |
10 | internal KeyboardInterruptError()
11 | : base(null) {
12 | base.Source = "Selenium";
13 | base.HResult = FACILITY_CONTROL_ERROR | 0x4004;
14 | }
15 |
16 | public override string Message {
17 | get {
18 | return "Code execution has been interrupted.";
19 | }
20 | }
21 |
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/Selenium/Errors/NotImplementedError.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Errors {
3 |
4 | ///
5 | ///
6 | ///
7 | public class NotImplementedError : SeleniumError {
8 | internal NotImplementedError()
9 | : base("The command is not yet implemented") { }
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Selenium/Errors/PdfErrors.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Errors {
3 |
4 | ///
5 | /// Pdf error
6 | ///
7 | public class PdfError : SeleniumError {
8 | internal PdfError(string message)
9 | : base(message) { }
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Selenium/Internal/AssemblyExt.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace Selenium.Internal {
4 |
5 | static class AssemblyExt {
6 |
7 | internal static T GetFirstAttribute(this Assembly assembly) {
8 | object[] attributes = assembly.GetCustomAttributes(typeof(T), false);
9 | if (attributes.Length == 0)
10 | return default(T);
11 | return (T)attributes[0];
12 | }
13 |
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Selenium/Internal/AssemblyURLAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Selenium.Internal {
4 |
5 | [AttributeUsage(AttributeTargets.Assembly)]
6 | class AssemblyURLAttribute : Attribute {
7 |
8 | public string URL;
9 |
10 | public AssemblyURLAttribute(string url) {
11 | this.URL = url;
12 | }
13 |
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Selenium/Internal/COMDisposable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Selenium.Internal {
6 |
7 | ///
8 | /// Adds a call on the Dispose method of a COM object when the reference count reaches 0.
9 | ///
10 | ///
11 | /// class MyClass : IMyClass, IDisposable {
12 | ///
13 | /// public MyClass() {
14 | /// COMDisposable.Subscribe(this, typeof(IMyClass));
15 | /// }
16 | ///
17 | /// public void Dispose() {
18 | ///
19 | /// }
20 | ///
21 | /// }
22 | ///
23 | class COMDisposable {
24 |
25 | delegate int ReleaseDelegate(IntPtr pUnk);
26 |
27 | static readonly int RELEASE_PTR_OFFSET = 2 * IntPtr.Size;
28 | static readonly Hashtable ITEMS = new Hashtable();
29 | static readonly ReleaseDelegate ReleaseNew = new ReleaseDelegate(Release);
30 | static readonly IntPtr ReleaseNewPtr = Marshal.GetFunctionPointerForDelegate(ReleaseNew);
31 |
32 | private ReleaseDelegate ReleaseOri;
33 | private int RefCountStart;
34 |
35 | public static void Subscribe(IDisposable instance, Type interfaceCOM) {
36 | IntPtr pUnk = Marshal.GetComInterfaceForObject(instance, interfaceCOM);
37 | IntPtr vtable = Marshal.ReadIntPtr(pUnk);
38 | COMDisposable item = (COMDisposable)ITEMS[vtable];
39 | if (item == null) {
40 | //gets the the Release function
41 | IntPtr releaseOriPtr = Marshal.ReadIntPtr(vtable, RELEASE_PTR_OFFSET);
42 | ReleaseDelegate releaseOri = (ReleaseDelegate)Marshal.GetDelegateForFunctionPointer(
43 | releaseOriPtr, typeof(ReleaseDelegate));
44 |
45 | //saves the original function and reference count
46 | item = new COMDisposable();
47 | item.ReleaseOri = releaseOri;
48 | item.RefCountStart = releaseOri(pUnk);
49 | ITEMS.Add(vtable, item);
50 |
51 | //overrides the Release function
52 | Marshal.WriteIntPtr(vtable, RELEASE_PTR_OFFSET, ReleaseNewPtr);
53 | } else {
54 | item.ReleaseOri(pUnk);
55 | }
56 | }
57 |
58 | private static int Release(IntPtr pUnk) {
59 | IntPtr vtable = Marshal.ReadIntPtr(pUnk);
60 | COMDisposable item = (COMDisposable)ITEMS[vtable];
61 |
62 | int refCount = item.ReleaseOri(pUnk);
63 | if (refCount < item.RefCountStart) {
64 | IDisposable obj = (IDisposable)Marshal.GetObjectForIUnknown(pUnk);
65 | item.ReleaseOri(pUnk);
66 | obj.Dispose();
67 | }
68 | return refCount;
69 | }
70 |
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/Selenium/Internal/COMExt.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using System;
3 | using System.Reflection;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium.Internal {
7 |
8 | class COMExt {
9 |
10 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
11 | delegate int CallBack([Out]out object result, ref object argument1, ref object argument2);
12 |
13 | public static object WaitUntilProc(object function, object argument1, object argument2, int timeout) {
14 | DateTime endtime = DateTime.UtcNow.AddMilliseconds(timeout);
15 | try {
16 | if (function is int) {
17 | //handles AddressOf
18 | var ptr = new IntPtr((int)function);
19 | CallBack callback0 = (CallBack)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CallBack));
20 | while (true) {
21 | object result = null;
22 | callback0(out result, ref argument1, ref argument2);
23 | if (result != null && !false.Equals(result))
24 | return result;
25 | if (DateTime.UtcNow > endtime)
26 | throw new Errors.TimeoutError(timeout);
27 | SysWaiter.Wait();
28 | }
29 | } else if (Marshal.IsComObject(function)) {
30 | Type t = function.GetType();
31 | object[] args = new object[] { argument1, argument2 };
32 | while (true) {
33 | object result = t.InvokeMember(string.Empty, BindingFlags.InvokeMethod, null, function, args);
34 | if (result != null && !false.Equals(result))
35 | return result;
36 | if (DateTime.UtcNow > endtime)
37 | throw new Errors.TimeoutError(timeout);
38 | SysWaiter.Wait();
39 | }
40 | } else {
41 | throw new Errors.ArgumentError("Invalid argument at position 0. A function is expected.");
42 | }
43 | } catch (ArgumentException) {
44 | throw new Errors.ArgumentError("The procedure has an invalide signature.");
45 | } catch (COMException ex) {
46 | throw new SeleniumError(ex.Message);
47 | }
48 | }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Selenium/Internal/COMRunningObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Runtime.InteropServices.ComTypes;
4 |
5 | namespace Selenium.Internal {
6 |
7 | class COMRunningObject : IDisposable {
8 |
9 | private int _obj_id;
10 |
11 | ///
12 | /// Register a COM instance in the running table
13 | ///
14 | /// Object instance
15 | /// Registration name
16 | ///
17 | public COMRunningObject(object instance, string name) {
18 | IRunningObjectTable rot;
19 | if (Native.GetRunningObjectTable(0, out rot) != 0)
20 | return;
21 |
22 | IMoniker moniker;
23 | int hresult = Native.CreateFileMoniker(name, out moniker);
24 | if (hresult == 0) {
25 | _obj_id = rot.Register(Native.ROTFLAGS_REGISTRATIONKEEPSALIVE
26 | , instance, moniker);
27 | Marshal.ReleaseComObject(moniker);
28 | }
29 |
30 | Marshal.ReleaseComObject(rot);
31 | }
32 |
33 | public void Dispose() {
34 | if (_obj_id == 0)
35 | return;
36 |
37 | try {
38 | Native.RevokeActiveObject(_obj_id, IntPtr.Zero);
39 | } catch { }
40 |
41 | _obj_id = 0;
42 | }
43 |
44 |
45 | class Native {
46 |
47 | const string OLE32 = "ole32.dll";
48 | const string OLEAUT32 = "oleaut32.dll";
49 |
50 | public const int ROTFLAGS_REGISTRATIONKEEPSALIVE = 1;
51 |
52 | [DllImport(OLE32)]
53 | public static extern int GetRunningObjectTable(
54 | int reserved, out IRunningObjectTable prot);
55 |
56 | [DllImport(OLE32)]
57 | public static extern int CreateFileMoniker(
58 | [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, out IMoniker ppmk);
59 |
60 | [DllImport(OLEAUT32)]
61 | public static extern int RevokeActiveObject(int handle, IntPtr reserved);
62 | }
63 |
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/Selenium/Internal/ClipboardExt.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Windows.Forms;
3 |
4 | namespace Selenium.Internal {
5 |
6 | class ClipboardExt {
7 |
8 | public static void SetText(string value) {
9 | ThreadExt.RunSTA(() => {
10 | Clipboard.SetText(value, TextDataFormat.UnicodeText);
11 | return 0;
12 | }, 6000);
13 | }
14 |
15 | public static void SetImage(Bitmap value) {
16 | ThreadExt.RunSTA(() => {
17 | Clipboard.SetImage(value);
18 | return 0;
19 | }, 6000);
20 | }
21 |
22 | public static string GetText() {
23 | string result = ThreadExt.RunSTA(() => {
24 | string text = Clipboard.GetText();
25 | return text;
26 | }, 6000);
27 | return result;
28 | }
29 |
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/Selenium/Internal/ExceptionDialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Text;
4 | using System.Windows.Forms;
5 |
6 | namespace Selenium.Internal {
7 |
8 | partial class ExceptionDialog : Form {
9 |
10 | private StringBuilder _sb;
11 |
12 | public ExceptionDialog(Exception exception) {
13 | System.Windows.Forms.Application.EnableVisualStyles();
14 | InitializeComponent();
15 |
16 | var assembly = typeof(ExceptionDialog).Assembly;
17 | var att = assembly.GetFirstAttribute();
18 | this.linkLabel1.Text = att.URL;
19 |
20 | _sb = new StringBuilder();
21 | while (exception != null) {
22 | _sb.AppendFormat("{0}: {1}\r\n", exception.GetType(), exception.Message);
23 | _sb.AppendLine(exception.StackTrace);
24 | _sb.AppendLine();
25 | exception = exception.InnerException;
26 | }
27 | textBox1.Text = _sb.ToString();
28 | textBox1.SelectionStart = 0;
29 | textBox1.SelectionLength = 0;
30 | textBox1.KeyDown += textBox1_KeyDown;
31 | }
32 |
33 | private void btCopy_Click(object sender, EventArgs e) {
34 | ClipboardExt.SetText(_sb.ToString());
35 | }
36 |
37 | private void btClose_Click(object sender, EventArgs e) {
38 | Close();
39 | }
40 |
41 | private void textBox1_KeyDown(object sender, KeyEventArgs e) {
42 | if (e.KeyCode == System.Windows.Forms.Keys.A && e.Control) {
43 | textBox1.SelectAll();
44 | e.Handled = true;
45 | }
46 | }
47 |
48 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
49 | Process.Start(((LinkLabel)sender).Text);
50 | }
51 |
52 | internal static void ShowDialog(Exception exception) {
53 | new ExceptionDialog(exception).ShowDialog();
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/Selenium/Internal/ImgExt.cs:
--------------------------------------------------------------------------------
1 | using Interop;
2 | using System;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Selenium.Internal {
8 |
9 | class ImgExt {
10 |
11 | public static IStdPicture ImageToPictureDisp(Bitmap bitmap) {
12 | var pictDescBitmap = new NativeMethods.PictDescBitmap(bitmap);
13 | object ppVoid = null;
14 | Guid guid = typeof(IStdPicture).GUID;
15 | NativeMethods.OleCreatePictureIndirect(pictDescBitmap, ref guid, true, out ppVoid);
16 | return (IStdPicture)ppVoid;
17 | }
18 |
19 | public static Bitmap RemoveAlphaChannel(Bitmap bitmapSrc) {
20 | Rectangle rect = new Rectangle(0, 0, bitmapSrc.Width, bitmapSrc.Height);
21 | Bitmap bitmapDest = (Bitmap)new Bitmap(bitmapSrc.Width, bitmapSrc.Height, PixelFormat.Format24bppRgb);
22 | BitmapData dataSrc = bitmapSrc.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
23 | BitmapData dataDest = bitmapDest.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
24 | NativeMethods.CopyMemory(dataDest.Scan0, dataSrc.Scan0, (uint)dataSrc.Stride * (uint)dataSrc.Height);
25 | bitmapSrc.UnlockBits(dataSrc);
26 | bitmapDest.UnlockBits(dataDest);
27 | return bitmapDest;
28 | }
29 |
30 | static class NativeMethods {
31 |
32 | const string KERNEL32 = "Kernel32.dll";
33 | const string OLEAUTH32 = "oleaut32.dll";
34 |
35 | [DllImport(KERNEL32)]
36 | public extern static void CopyMemory(IntPtr dest, IntPtr src, uint length);
37 |
38 | [StructLayout(LayoutKind.Sequential)]
39 | public class PictDescBitmap {
40 | internal int cbSizeOfStruct = Marshal.SizeOf(typeof(PictDescBitmap));
41 | internal int pictureType = 1;
42 | internal IntPtr hBitmap = IntPtr.Zero;
43 | internal IntPtr hPalette = IntPtr.Zero;
44 | internal int unused = 0;
45 |
46 | internal PictDescBitmap(Bitmap bitmap) {
47 | this.hBitmap = bitmap.GetHbitmap();
48 | }
49 | }
50 |
51 | [DllImport(OLEAUTH32, PreserveSig = true)]
52 | public static extern int OleCreatePictureIndirect(
53 | [In] PictDescBitmap pictdesc, ref Guid iid, bool fOwn,
54 | [MarshalAs(UnmanagedType.Interface)] out object ppVoid);
55 |
56 | }
57 |
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/Selenium/Internal/IniFile.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 |
4 | namespace Selenium.Internal {
5 |
6 | class IniFile {
7 |
8 | ///
9 | /// Parse a Windows ini file without marshaling the values.
10 | /// Multiline values are not supported
11 | /// Incorrect sections or properties are silently skipped
12 | ///
13 | /// File path
14 | /// IniFile
15 | public static Dictionary> Load(string filePath) {
16 | var sections = new Dictionary>();
17 | using (var reader = new StreamReader(filePath)) {
18 | Dictionary section = null;
19 | string section_key = null;
20 | while (!reader.EndOfStream) {
21 | string line = reader.ReadLine().Trim();
22 | if (line.Length == 0 || line[0] == ';')
23 | continue;
24 |
25 | if (line[0] == '[' && line[line.Length - 1] == ']') {
26 | if (section != null)
27 | sections.Add(section_key, section);
28 | section = new Dictionary();
29 | section_key = line.Substring(1, line.Length - 2);
30 | } else if (section != null) {
31 | int i = line.IndexOf('=');
32 | if (i > 0) {
33 | string prop_key = line.Substring(0, i).Trim();
34 | if (++i < line.Length) {
35 | section[prop_key] = line.Substring(i).Trim();
36 | } else {
37 | section[prop_key] = string.Empty;
38 | }
39 | }
40 | }
41 | }
42 | if (section != null)
43 | sections.Add(section_key, section);
44 | }
45 | return sections;
46 | }
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/Selenium/Internal/ThreadExt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace Selenium.Internal {
5 |
6 | class ThreadExt {
7 |
8 | ///
9 | /// Invoke a function on a new single thread.
10 | ///
11 | /// Returned value
12 | /// Function
13 | /// Execution timeout
14 | ///
15 | public static T RunSTA(Func func, int timeout) {
16 | T result = default(T);
17 | Exception exception = null;
18 | using (var evt = new EventWaitHandle(false, EventResetMode.ManualReset)) {
19 | Thread thread = new Thread(() => {
20 | try {
21 | result = func();
22 | } catch (Exception ex) {
23 | exception = ex;
24 | }
25 | evt.Set();
26 | });
27 | thread.TrySetApartmentState(ApartmentState.STA);
28 | thread.Start();
29 | evt.WaitOne(timeout, true);
30 | }
31 | if (exception != null)
32 | throw new SeleniumException(exception);
33 | return result;
34 | }
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/Selenium/Internal/UnhandledException.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Internal;
2 | using System;
3 | using System.Threading;
4 |
5 | namespace Selenium.Core {
6 |
7 | static class UnhandledException {
8 |
9 | private static UnhandledExceptionEventHandler _callback = null;
10 | private static Thread _thread = null;
11 |
12 | public static void Initialize() {
13 | if (_callback != null)
14 | return;
15 |
16 | _callback = new UnhandledExceptionEventHandler(On_UnhandledException);
17 | AppDomain.CurrentDomain.UnhandledException += _callback;
18 | }
19 |
20 | private static void On_UnhandledException(object sender, UnhandledExceptionEventArgs ex_arg) {
21 | if (ex_arg.ExceptionObject is ThreadAbortException)
22 | return;
23 | //Display the exception message box on another thread
24 | _thread = new Thread(new ParameterizedThreadStart((ex) =>
25 | ExceptionDialog.ShowDialog((Exception)ex)
26 | ));
27 | _thread.IsBackground = true;
28 | SysWaiter.Signal();
29 | _thread.Start(ex_arg.ExceptionObject);
30 | }
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/Excel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Interop.Excel {
5 |
6 | [Guid("00024500-0000-0000-C000-000000000046"), ComImport, TypeLibType(2), ClassInterface((short)0)]
7 | class Excel { }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/ICells.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Interop.Excel {
6 | #pragma warning disable 1591
7 |
8 | ///
9 | /// Range interface with the Resize property as an indexer
10 | ///
11 | [Guid("00020846-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4096)]
12 | interface ICells {
13 |
14 | [DispId(0), IndexerName("_Default")]
15 | object this[[MarshalAs(UnmanagedType.Struct), In, Optional] object RowIndex, [MarshalAs(UnmanagedType.Struct), In, Optional] object ColumnIndex] {
16 | [TypeLibFunc((short)1024), DispId(0), MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
17 | get;
18 | [TypeLibFunc((short)1024), DispId(0), MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
19 | set;
20 | }
21 |
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/IExcel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Interop.Excel {
6 | #pragma warning disable 1591
7 |
8 | ///
9 | /// Range interface with the Range property as an indexer
10 | ///
11 | [Guid("000208D5-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4160)]
12 | public interface IExcel {
13 |
14 | [DispId(197), IndexerName("Range")]
15 | IRange this[[MarshalAs(UnmanagedType.Struct), In] object Cell1, [MarshalAs(UnmanagedType.Struct), In, Optional] object Cell2] {
16 | [TypeLibFunc((short)1024), DispId(0), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
17 | get;
18 | }
19 |
20 | [DispId(283), TypeLibFunc((short)64), LCIDConversion(1)]
21 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
22 | void Save([MarshalAs(UnmanagedType.Struct), In, Optional] object Filename);
23 |
24 | [DispId(494)]
25 | IWorksheets Worksheets {
26 | [DispId(494), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
27 | get;
28 | }
29 |
30 | [DispId(572)]
31 | IWorkbooks Workbooks {
32 | [DispId(572), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
33 | get;
34 | }
35 |
36 | [DispId(558)]
37 | bool Visible {
38 | [DispId(558), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
39 | get;
40 | [DispId(558), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
41 | set;
42 | }
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/IListObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Interop.Excel {
7 | #pragma warning disable 1591
8 |
9 | ///
10 | /// Workbook interface
11 | ///
12 | [Guid("00024471-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4160)]
13 | public interface IListObject {
14 |
15 | [DispId(2313)]
16 | IRange HeaderRowRange {
17 | [DispId(2313), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
18 | get;
19 | }
20 |
21 | [DispId(705)]
22 | IRange DataBodyRange {
23 | [DispId(705), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
24 | get;
25 | }
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/IWorkbook.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Interop.Excel {
7 | #pragma warning disable 1591
8 |
9 | ///
10 | /// Workbook interface
11 | ///
12 | [Guid("000208DA-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4160)]
13 | public interface IWorkbook {
14 |
15 | [DispId(181), LCIDConversion(1)]
16 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
17 | [return: MarshalAs(UnmanagedType.Interface)]
18 | IWorkbook Add([MarshalAs(UnmanagedType.Struct), In, Optional] object Template);
19 |
20 | [DispId(494)]
21 | IWorksheets Worksheets {
22 | [DispId(494), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
23 | get;
24 | }
25 |
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/IWorkbooks.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Interop.Excel {
7 | #pragma warning disable 1591
8 |
9 | ///
10 | /// Workbooks interface
11 | ///
12 | [Guid("000208DB-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4288)]
13 | public interface IWorkbooks {
14 |
15 | [DispId(181)]
16 | [LCIDConversion(1)]
17 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
18 | [return: MarshalAs(UnmanagedType.Interface)]
19 | IWorkbook Add([MarshalAs(UnmanagedType.Struct), In, Optional] object Template);
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/IWorksheet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Interop.Excel {
6 | #pragma warning disable 1591
7 |
8 | ///
9 | /// Worksheet interface
10 | ///
11 | [Guid("000208D8-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4288)]
12 | public interface IWorksheet {
13 |
14 | [DispId(412)]
15 | IRange UsedRange {
16 | [LCIDConversion(0), DispId(412), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
17 | get;
18 | }
19 |
20 | [DispId(211), LCIDConversion(2)]
21 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
22 | void Paste([MarshalAs(UnmanagedType.Struct), In, Optional] object Destination
23 | , [MarshalAs(UnmanagedType.Struct), In, Optional] object Link);
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/Selenium/Interop/Excel/IWorksheets.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Interop.Excel {
6 | #pragma warning disable 1591
7 |
8 | ///
9 | /// Worksheets interface
10 | ///
11 | [Guid("000208D7-0000-0000-C000-000000000046"), ComImport, InterfaceType(2), TypeLibType(4288)]
12 | public interface IWorksheets {
13 |
14 | [DispId(0), IndexerName("_Default")]
15 | IWorksheet this[[MarshalAs(UnmanagedType.Struct), In] object Index] {
16 | [DispId(0), TypeLibFunc((short)1024), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
17 | get;
18 | }
19 |
20 | [DispId(118)]
21 | int Count {
22 | [DispId(118), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
23 | get;
24 | }
25 |
26 | [DispId(181), LCIDConversion(4)]
27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
28 | [return: MarshalAs(UnmanagedType.IDispatch)]
29 | IWorksheet Add([MarshalAs(UnmanagedType.Struct), In, Optional] object Before
30 | , [MarshalAs(UnmanagedType.Struct), In, Optional] object After
31 | , [MarshalAs(UnmanagedType.Struct), In, Optional] object Count
32 | , [MarshalAs(UnmanagedType.Struct), In, Optional] object Type);
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/Selenium/Interop/IStdPicture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Interop {
5 |
6 | [Guid("7BF80981-BF32-101A-8BBB-00AA00300CAB"), ComImport]
7 | public interface IStdPicture { }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/Selenium/NamespaceDoc.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | namespace Selenium {
4 |
5 | ///
6 | /// These are the namespace comments.
7 | ///
8 | ///
9 | /// VBA:
10 | ///
11 | /// Public Sub Script()
12 | /// Dim driver As New FirefoxDriver
13 | /// driver.Get "http://www.google.com"
14 | /// ...
15 | /// driver.Quit
16 | /// End Sub
17 | ///
18 | ///
19 | /// VBScript:
20 | ///
21 | /// Class Script
22 | /// Dim driver
23 | ///
24 | /// Sub Class_Initialize
25 | /// Set driver = CreateObject("Selenium.FirefoxDriver")
26 | /// driver.Get "http://www.google.com"
27 | /// End Sub
28 | ///
29 | /// Sub Class_Terminate
30 | /// driver.Quit
31 | /// End Sub
32 | /// End Class
33 | ///
34 | /// Set s = New Script
35 | ///
36 | ///
37 | [CompilerGeneratedAttribute()]
38 | public class NamespaceDoc { }
39 | }
40 |
--------------------------------------------------------------------------------
/Selenium/Pdf/PdfOutlines.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 |
4 | namespace Selenium.Pdf {
5 |
6 | class PdfOutlines {
7 |
8 | class PdfOutline {
9 | public int Id;
10 | public string Text;
11 | public int Page;
12 | public int Y;
13 | }
14 |
15 | private List _outlines = new List();
16 |
17 | public int Count {
18 | get {
19 | return _outlines.Count;
20 | }
21 | }
22 |
23 | public void Add(int id, string text, int page, int y) {
24 | _outlines.Add(new PdfOutline {
25 | Id = id,
26 | Text = text,
27 | Page = page,
28 | Y = y
29 | });
30 | }
31 |
32 | public void Write(StreamWriter writer, PdfXRefs xrefs) {
33 |
34 | //Write the outlines entries
35 | int count = _outlines.Count;
36 | for (int i = 0; i < count; i++) {
37 | PdfOutline outline = _outlines[i];
38 | xrefs.RegisterObject(outline.Id);
39 | writer.WriteLine(outline.Id + " 0 obj");
40 | writer.WriteLine("<<");
41 | writer.WriteLine("/Title (" + PdfWriter.EscapeText(outline.Text) + ")");
42 | writer.WriteLine("/Parent " + PdfXRefs.ID_OUTLINES + " 0 R");
43 | writer.Write("/Dest [ ");
44 | writer.Write(outline.Page);
45 | writer.Write(" 0 R /XYZ null ");
46 | writer.Write(outline.Y == -1 ? "null" : outline.Y.ToString());
47 | writer.WriteLine(" 0 ]");
48 | if (i > 0)
49 | writer.WriteLine("/Prev " + _outlines[i - 1].Id + " 0 R");
50 | if (i < count - 1)
51 | writer.WriteLine("/Next " + _outlines[i + 1].Id + " 0 R");
52 | writer.WriteLine(">>");
53 | writer.WriteLine("endobj");
54 | }
55 |
56 | //Write the main entry
57 | xrefs.RegisterObject(PdfXRefs.ID_OUTLINES);
58 | writer.WriteLine(PdfXRefs.ID_OUTLINES + " 0 obj");
59 | writer.WriteLine("<<");
60 | writer.WriteLine("/Type /Outlines");
61 | if (_outlines.Count == 0) {
62 | writer.WriteLine("/Count 0");
63 | writer.WriteLine("/First null");
64 | writer.WriteLine("/Last null");
65 | } else {
66 | writer.WriteLine("/Count " + count);
67 | writer.WriteLine("/First " + _outlines[0].Id + " 0 R");
68 | writer.WriteLine("/Last " + _outlines[count - 1].Id + " 0 R");
69 | }
70 | writer.WriteLine(">>");
71 | writer.WriteLine("endobj");
72 | }
73 |
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/Selenium/Pdf/PdfPage.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 |
4 | namespace Selenium.Pdf {
5 |
6 | class PdfPage {
7 |
8 | public class XObject {
9 | public int Id;
10 | public string CodeName;
11 | }
12 |
13 | public readonly int Id;
14 | public int Height;
15 | public int Width;
16 | public readonly List Contents = new List();
17 | public readonly List Annots = new List();
18 | public readonly List XObjects = new List();
19 |
20 | public PdfPage(int id, int width, int height) {
21 | Id = id;
22 | Height = height;
23 | Width = width;
24 | }
25 |
26 | internal void AddContent(int id) {
27 | Contents.Add(id);
28 | }
29 |
30 | internal void AddXObject(int id, string codeName) {
31 | XObjects.Add(new XObject {
32 | Id = id,
33 | CodeName = codeName
34 | });
35 | }
36 |
37 | internal void AddAnnot(int id) {
38 | Annots.Add(id);
39 | }
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Selenium/Pdf/PdfXRefs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace Selenium.Pdf {
5 |
6 | class PdfXRefs {
7 |
8 | public const int ID_EMPTY = 0;
9 | public const int ID_CATALOGUE = 1;
10 | public const int ID_INFO = 2;
11 | public const int ID_PAGES = 3;
12 | public const int ID_FONTS = 4;
13 | public const int ID_OUTLINES = 5;
14 | public const int ID_START_GENERATE = 6;
15 |
16 | private StreamWriter _pdfWriter;
17 | private long[] _buffer = new long[100];
18 | private int _count = ID_START_GENERATE;
19 |
20 | public PdfXRefs(StreamWriter writer) {
21 | _pdfWriter = writer;
22 | }
23 |
24 | public int Count {
25 | get {
26 | return _count;
27 | }
28 | }
29 |
30 | public int CreateObject() {
31 | return _count++;
32 | }
33 |
34 | public void RegisterObject(int id) {
35 | _pdfWriter.Flush();
36 | RegisterObject(id, _pdfWriter.BaseStream.Position);
37 | }
38 |
39 | public int CreateAndRegisterObject() {
40 | int id = _count++;
41 | RegisterObject(id);
42 | return id;
43 | }
44 |
45 | ///
46 | /// Adds a new position in the reference table.
47 | ///
48 | public void RegisterObject(int id, long position) {
49 | if (id >= _buffer.Length)
50 | IncreaseCapacity();
51 | _buffer[id] = position;
52 | }
53 |
54 | ///
55 | /// Writes the xref table to the pdf stream.
56 | ///
57 | ///
58 | public long Write() {
59 | _pdfWriter.Flush();
60 | long position = _pdfWriter.BaseStream.Position;
61 | int count = _count;
62 |
63 | _pdfWriter.WriteLine("xref");
64 | _pdfWriter.WriteLine("0 " + count); //First and last object number
65 | _pdfWriter.Write("0000000000 65535 f\r\n");
66 | for (int i = 1; i < count; i++) {
67 | _pdfWriter.Write(_buffer[i].ToString().PadLeft(10, '0'));
68 | _pdfWriter.Write(" 00000 n\r\n");
69 | }
70 |
71 | return position;
72 | }
73 |
74 | ///
75 | /// Increase the capacity of the buffer holding the positions.
76 | ///
77 | private void IncreaseCapacity() {
78 | long[] newBuffer = new long[_buffer.Length * 2];
79 | Array.Copy(_buffer, newBuffer, _count);
80 | _buffer = newBuffer;
81 | }
82 |
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/Selenium/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Resources;
4 | using System.Runtime.InteropServices;
5 | using System.Runtime.CompilerServices;
6 | using Selenium.Internal;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("Selenium .Net/COM binding")]
12 | [assembly: AssemblyDescription("Selenium Type Library")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCompany("Florent BREHERET")]
15 | [assembly: AssemblyProduct("SeleniumBasic")]
16 | [assembly: AssemblyCopyright("")]
17 | [assembly: AssemblyURL(@"https://github.com/florentbr/SeleniumBasic")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("0277FC34-FD1B-4616-BB19-A9AABCAF2A70")]
28 |
29 | // Version information for an assembly consists of the following four values:
30 | //
31 | // Major Version
32 | // Minor Version
33 | // Build Number
34 | // Revision
35 | //
36 | // You can specify all the values or you can default the Build and Revision Numbers
37 | // by using the '*' as shown below:
38 | // [assembly: AssemblyVersion("1.0.*")]
39 | [assembly: AssemblyVersion("2.0.9.0")]
40 | [assembly: AssemblyFileVersion("2.0.9.0")]
41 | [assembly: TypeLibVersion(2, 0)]
42 |
43 | [assembly: NeutralResourcesLanguage("en-US")]
44 |
45 | #if Test
46 | [assembly: InternalsVisibleTo("Selenium.Tests")]
47 | #endif
48 |
49 |
--------------------------------------------------------------------------------
/Selenium/SeleniumError.cs:
--------------------------------------------------------------------------------
1 | using Selenium;
2 |
3 | namespace Selenium {
4 |
5 | ///
6 | /// Selenium base error class.
7 | ///
8 | public class SeleniumError : SeleniumException {
9 |
10 | protected const int FACILITY_CONTROL_ERROR = unchecked((int)0xA00A0000);
11 |
12 | ///
13 | public Dictionary ResponseData { get; internal set; }
14 | private string _message;
15 |
16 | internal SeleniumError(string message, params object[] args)
17 | : this(args.Length > 0 ? string.Format(message, args) : message, 0) {
18 | }
19 |
20 | internal SeleniumError(int code, string message, params object[] args)
21 | : this(args.Length > 0 ? string.Format(message, args) : message, code) {
22 | }
23 |
24 | internal SeleniumError(string message, int code = 0) {
25 | _message = message;
26 | base.HResult = FACILITY_CONTROL_ERROR | code;
27 | }
28 |
29 | ///
30 | /// Exception message
31 | ///
32 | public override string Message {
33 | get {
34 | var typename = this.GetType().Name;
35 | return string.Format("{0}\n{1}", typename, _message);
36 | }
37 | }
38 |
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/Selenium/SeleniumException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Reflection;
5 |
6 | namespace Selenium {
7 |
8 | ///
9 | /// Selenium base exception class.
10 | ///
11 | public class SeleniumException : Exception {
12 |
13 | internal SeleniumException()
14 | : base() {}
15 |
16 | internal SeleniumException(Exception exception)
17 | : base(exception.Message, exception) {
18 | EventLog.WriteEntry("SeleniumBasic", this.Message, EventLogEntryType.Error);
19 | }
20 |
21 | internal SeleniumException(string message, params object[] args)
22 | : base(args.Length > 0 ? string.Format(message, args) : message) {
23 | EventLog.WriteEntry("SeleniumBasic", this.Message, EventLogEntryType.Error);
24 | }
25 |
26 | ///
27 | /// Exception message
28 | ///
29 | public override string Message {
30 | get {
31 | StackTrace stack = new StackTrace(base.InnerException ?? this, true);
32 |
33 | string filename = null;
34 | int errline = 0;
35 | for (int i = 0; i < stack.FrameCount; i++) {
36 | StackFrame frame = stack.GetFrame(i);
37 | string filepath = frame.GetFileName();
38 | if (filepath != null) {
39 | filename = Path.GetFileName(filepath);
40 | errline = frame.GetFileLineNumber();
41 | break;
42 | }
43 | }
44 |
45 | string typename = (base.InnerException ?? this).GetType().FullName;
46 | string message = base.InnerException == null ?
47 | base.Message : base.InnerException.Message;
48 |
49 | return string.Format("{2}\nLine {0} in {1}\n{3}"
50 | , errline, filename, typename, message);
51 | }
52 | }
53 |
54 | ///
55 | /// Exception source
56 | ///
57 | public override string Source {
58 | get { return "Selenium"; }
59 | }
60 |
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Selenium/Serializer/IJsonBinary.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace Selenium.Serializer {
4 |
5 | ///
6 | /// Interface to serialize to a base64 string.
7 | ///
8 | internal interface IJsonBinary {
9 | void Save(Stream stream);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Selenium/Serializer/IJsonObject.cs:
--------------------------------------------------------------------------------
1 | using JsonObject = Selenium.Dictionary;
2 |
3 | namespace Selenium.Serializer {
4 |
5 | ///
6 | /// Interface to serialize to a Json object.
7 | ///
8 | internal interface IJsonObject {
9 | JsonObject SerializeJson();
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Selenium/Serializer/JsonException.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Selenium.Serializer {
3 |
4 | ///
5 | /// Json serializer exception
6 | ///
7 | class JsonException : SeleniumException {
8 |
9 | internal JsonException(string message)
10 | : base(message) { }
11 |
12 | internal JsonException(string message, byte[] data, int index)
13 | : base(string.Format("{0} (position: {1})", message, index)) { }
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Selenium/Struct/Point.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using System;
3 | using System.Diagnostics;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium {
7 |
8 | ///
9 | /// Point structure
10 | ///
11 | [Guid("0277FC34-FD1B-4616-BB19-E1305CCF61EC")]
12 | [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
13 | [DebuggerDisplay("X={X} Y={Y}")]
14 | public class Point : ComInterfaces._Point {
15 |
16 | private int _x, _y;
17 |
18 | internal Point(Dictionary dict) {
19 | try {
20 | _x = Convert.ToInt32(dict["x"]);
21 | _y = Convert.ToInt32(dict["y"]);
22 | } catch (Errors.KeyNotFoundError ex) {
23 | throw new DeserializeException(typeof(Point), ex);
24 | } catch (InvalidCastException ex) {
25 | throw new DeserializeException(typeof(Point), ex);
26 | }
27 | }
28 |
29 | ///
30 | /// Point construcor
31 | ///
32 | ///
33 | ///
34 | public Point(int x, int y) {
35 | _x = x;
36 | _y = y;
37 | }
38 |
39 | ///
40 | /// X
41 | ///
42 | public int X {
43 | get { return _x; }
44 | }
45 |
46 | ///
47 | /// Y
48 | ///
49 | public int Y {
50 | get { return _y; }
51 | }
52 |
53 | ///
54 | /// Returns the text representaton of this instance
55 | ///
56 | ///
57 | public override string ToString() {
58 | return string.Format(@"{{x={0} y={1}}}", _x, _y);
59 | }
60 |
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Selenium/Struct/Size.cs:
--------------------------------------------------------------------------------
1 | using Selenium.Core;
2 | using System;
3 | using System.Diagnostics;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Selenium {
7 |
8 | ///
9 | /// Size structure
10 | ///
11 | [Guid("0277FC34-FD1B-4616-BB19-2108C1FE2EE9")]
12 | [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
13 | [DebuggerDisplay("Width={Width} Height={Height}")]
14 | public class Size : ComInterfaces._Size {
15 |
16 | private int _width, _height;
17 |
18 | ///
19 | /// Get the size
20 | ///
21 | ///
22 | ///
23 | public Size(int width, int height) {
24 | _width = width;
25 | _height = height;
26 | }
27 |
28 | internal Size(Dictionary dict) {
29 | try {
30 | _width = Convert.ToInt32(dict["width"]);
31 | _height = Convert.ToInt32(dict["height"]);
32 | } catch (Errors.KeyNotFoundError ex) {
33 | throw new DeserializeException(typeof(Size), ex);
34 | } catch (InvalidCastException ex) {
35 | throw new DeserializeException(typeof(Size), ex);
36 | }
37 | }
38 |
39 | ///
40 | /// Width
41 | ///
42 | public int Width {
43 | get { return _width; }
44 | }
45 |
46 | ///
47 | /// Height
48 | ///
49 | public int Height {
50 | get { return _height; }
51 | }
52 |
53 | ///
54 | /// Returns the text representaton of this instance.
55 | ///
56 | ///
57 | public override string ToString() {
58 | return string.Format(@"{{width={0} height={1}}}", _width, _height);
59 | }
60 |
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Selenium/Zip/ZipException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Selenium.Zip {
4 |
5 | class ZipException : Exception {
6 | public ZipException(string message)
7 | : base(message) { }
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/Selenium/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Selenium/key.snk
--------------------------------------------------------------------------------
/SeleniumBasic.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Selenium", "Selenium\Selenium.csproj", "{B30CE36F-3653-4610-9519-FAA61E8FC12B}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Selenium.Tests", "Selenium.Tests\Selenium.Tests.csproj", "{09D6B13B-4B98-43E8-AB8E-8BE14C515E37}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VbsConsole", "VbsConsole\VbsConsole.csproj", "{FB9F9DAE-3024-49AF-B017-8AECFDECF844}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | Test|Any CPU = Test|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {B30CE36F-3653-4610-9519-FAA61E8FC12B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {B30CE36F-3653-4610-9519-FAA61E8FC12B}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {B30CE36F-3653-4610-9519-FAA61E8FC12B}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {B30CE36F-3653-4610-9519-FAA61E8FC12B}.Release|Any CPU.Build.0 = Release|Any CPU
23 | {B30CE36F-3653-4610-9519-FAA61E8FC12B}.Test|Any CPU.ActiveCfg = Test|Any CPU
24 | {B30CE36F-3653-4610-9519-FAA61E8FC12B}.Test|Any CPU.Build.0 = Test|Any CPU
25 | {09D6B13B-4B98-43E8-AB8E-8BE14C515E37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {09D6B13B-4B98-43E8-AB8E-8BE14C515E37}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {09D6B13B-4B98-43E8-AB8E-8BE14C515E37}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {09D6B13B-4B98-43E8-AB8E-8BE14C515E37}.Test|Any CPU.ActiveCfg = Test|Any CPU
29 | {09D6B13B-4B98-43E8-AB8E-8BE14C515E37}.Test|Any CPU.Build.0 = Test|Any CPU
30 | {FB9F9DAE-3024-49AF-B017-8AECFDECF844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {FB9F9DAE-3024-49AF-B017-8AECFDECF844}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {FB9F9DAE-3024-49AF-B017-8AECFDECF844}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {FB9F9DAE-3024-49AF-B017-8AECFDECF844}.Test|Any CPU.ActiveCfg = Release|Any CPU
34 | {FB9F9DAE-3024-49AF-B017-8AECFDECF844}.Test|Any CPU.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/Templates/Selenium(advanced).vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Templates/Selenium(advanced).vbs
--------------------------------------------------------------------------------
/Templates/Selenium.au3:
--------------------------------------------------------------------------------
1 | ; AutoIt script template with Selenium
2 | ; https://www.autoitscript.com
3 | ;
4 |
5 | Func Main()
6 | ; Launch the browser and open an URL
7 | Dim $driver = ObjCreate("Selenium.FirefoxDriver")
8 | $driver.Get("https://en.wikipedia.org/wiki/Main_Page")
9 |
10 | $driver.Wait(2000)
11 |
12 | $driver.Quit
13 | EndFunc
14 |
15 | Main()
--------------------------------------------------------------------------------
/Templates/Selenium.vbs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Templates/Selenium.vbs
--------------------------------------------------------------------------------
/Templates/Selenium.xltm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/florentbr/SeleniumBasic/8a2cde358d2bc06e3014aca2c8d427bc61188a1b/Templates/Selenium.xltm
--------------------------------------------------------------------------------
/Utils/CleanRegistry.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | echo Clean registry ...
4 |
5 | set f=%TEMP%\reglist.txt
6 | IF EXIST %f% del /F %f%
7 |
8 | REG QUERY HKLM\Software\Classes /f "Selenium." /k /s >> %f%
9 | REG QUERY HKCU\Software\Classes /f "Selenium." /k /s >> %f%
10 | REG QUERY HKLM\SOFTWARE\Classes /f "{0277FC34-FD1B-4616-BB19" /k /s>> %f%
11 | REG QUERY HKCU\SOFTWARE\Classes /f "{0277FC34-FD1B-4616-BB19" /k /s>> %f%
12 |
13 | setlocal enableextensions enabledelayedexpansion
14 | for /f "tokens=*" %%a in (%f%) do (
15 | Set line=%%a
16 | if "!line:~,5!"=="HKEY_" (
17 | echo !line!
18 | REG DELETE !line! /f
19 | )
20 | )
21 | endlocal
22 |
23 |
24 | echo Done.
25 | pause
--------------------------------------------------------------------------------
/VbsConsole/ConsoleArgument.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace vbsc {
3 |
4 | class ConsoleArgument {
5 |
6 | public string Id;
7 | public string Pattern;
8 | public object Value;
9 | public string Help;
10 | public string Info = null;
11 |
12 | public override string ToString() {
13 | if (Info != null) {
14 | return ' ' + Help + "\r\n " + Info;
15 | } else {
16 | return ' ' + Help;
17 | }
18 | }
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/VbsConsole/ExitException.cs:
--------------------------------------------------------------------------------
1 | using Interop.MSScript;
2 | using System;
3 |
4 | namespace vbsc {
5 |
6 | class ExitException : Exception {
7 |
8 | const string SOURCE_NAME = "WScript.Exit";
9 |
10 | public ExitException(int code)
11 | : base(string.Concat("Exit code: ", code)) {
12 | base.Source = SOURCE_NAME;
13 | base.HResult = unchecked((int)0x80000000U | code);
14 | }
15 |
16 | public static bool Is(IMSScriptError error) {
17 | return error.Source == SOURCE_NAME;
18 | }
19 |
20 | public static bool Is(Exception ex) {
21 | return ex.Source == SOURCE_NAME;
22 | }
23 |
24 | public static int ExitCode(IMSScriptError err) {
25 | return unchecked((int)0x7FFFFFFFU & err.Number);
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/VbsConsole/IWscript.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace vbsc {
6 |
7 | [ComVisible(true)]
8 | [Guid("047DEC5A-95C1-4C86-827F-7B8C92EBA67B")]
9 | public interface IWscript {
10 |
11 | [DispId(0)]
12 | string Name { get; }
13 |
14 | [DispId(100)]
15 | IWscript Application { get; }
16 |
17 | [DispId(1002)]
18 | object Arguments(int index = -1);
19 |
20 | [DispId(2001)]
21 | void Echo(object message);
22 |
23 | [DispId(101)]
24 | string FullName { get; }
25 |
26 | [DispId(102)]
27 | string Path { get; }
28 |
29 | [DispId(1001)]
30 | string ScriptFullName { get; }
31 |
32 | [DispId(2000)]
33 | object CreateObject(string strProgID, string strPrefix = null);
34 |
35 | [DispId(2002)]
36 | object GetObject(string strPathname = null, string strProgID = null, string strPrefix = null);
37 |
38 | [DispId(1000)]
39 | string ScriptName { get; }
40 |
41 | [DispId(2004)]
42 | void Sleep(int timems);
43 |
44 | [DispId(1008)]
45 | TextWriter StdErr { get; }
46 |
47 | [DispId(1006)]
48 | TextReader StdIn { get; }
49 |
50 | [DispId(1007)]
51 | TextWriter StdOut { get; }
52 |
53 | [DispId(200)]
54 | void Quit(int exitcode = 0);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/VbsConsole/Interop/IMSScriptControl_Events.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Interop.MSScript {
4 |
5 | public delegate void DScriptControlSource_ErrorEventHandler();
6 | public delegate void DScriptControlSource_TimeoutEventHandler();
7 |
8 | [InterfaceType(2), TypeLibType((short)16)]
9 | [ComEventInterface(typeof(IMSScriptControl_EventSink), typeof(MSScriptControl_EventProvider))]
10 | public interface IMSScriptControl_Events {
11 |
12 | event DScriptControlSource_ErrorEventHandler ErrorEvent;
13 | event DScriptControlSource_TimeoutEventHandler TimeoutEvent;
14 |
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/VbsConsole/Interop/IMSScriptError.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Interop.MSScript {
5 |
6 | [Guid("70841C78-067D-11D0-95D8-00A02463AB28")]
7 | [ComImport(), InterfaceType(2), TypeLibType(4304)]
8 | public interface IMSScriptError {
9 |
10 | [DispId(201)]
11 | int Number { [DispId(201), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
12 |
13 | [DispId(202)]
14 | string Source { [DispId(202), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
15 |
16 | [DispId(203)]
17 | string Description { [DispId(203), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
18 |
19 | [DispId(204)]
20 | string HelpFile { [DispId(204), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
21 |
22 | [DispId(205)]
23 | int HelpContext { [DispId(205), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
24 |
25 | [DispId(-517)]
26 | string Text { [DispId(-517), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
27 |
28 | [DispId(206)]
29 | int Line { [DispId(206), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
30 |
31 | [DispId(-529)]
32 | int Column { [DispId(-529), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
33 |
34 | [DispId(208)]
35 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
36 | void Clear();
37 |
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/IMSScriptModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Interop.MSScript {
6 |
7 | [Guid("0E59F1DC-1FBE-11D0-8FF2-00A0D10038BC")]
8 | [ComImport, ClassInterface((short)0)]
9 | public class MSScriptModule {
10 |
11 | }
12 |
13 | [Guid("70841C70-067D-11D0-95D8-00A02463AB28")]
14 | [ComImport(), InterfaceType(2), TypeLibType(4304), CoClass(typeof(MSScriptModule))]
15 | public interface IMSScriptModule {
16 |
17 | [DispId(0)]
18 | string Name { [DispId(0), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
19 |
20 | [DispId(1000)]
21 | object CodeObject { [DispId(1000), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
22 |
23 | [DispId(1001)]
24 | IMSScriptProcedures Procedures { [DispId(1001), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
25 |
26 | [DispId(2000)]
27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
28 | void AddCode([MarshalAs(UnmanagedType.BStr), In] string Code);
29 |
30 | [DispId(2001)]
31 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
32 | [return: MarshalAs(UnmanagedType.Struct)]
33 | object Eval([MarshalAs(UnmanagedType.BStr), In] string Expression);
34 |
35 | [DispId(2002)]
36 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
37 | void ExecuteStatement([MarshalAs(UnmanagedType.BStr), In] string Statement);
38 |
39 | [DispId(2003)]
40 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
41 | [return: MarshalAs(UnmanagedType.Struct)]
42 | object Run([MarshalAs(UnmanagedType.BStr), In] string ProcedureName, [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT), In] params object[] Parameters);
43 |
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/IMSScriptModules.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Runtime.InteropServices.CustomMarshalers;
5 |
6 | namespace Interop.MSScript {
7 |
8 | [Guid("70841C6F-067D-11D0-95D8-00A02463AB28")]
9 | [ComImport(), InterfaceType(2), TypeLibType(4304)]
10 | public interface IMSScriptModules : IEnumerable {
11 |
12 | [DispId(0)]
13 | IMSScriptModule this[[MarshalAs(UnmanagedType.Struct), In] object Index] { [DispId(0), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
14 |
15 | [DispId(1)]
16 | int Count { [DispId(1), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
17 |
18 | [DispId(-4)]
19 | [TypeLibFunc((short)64)]
20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
21 | [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(EnumeratorToEnumVariantMarshaler))]
22 | IEnumerator GetEnumerator();
23 |
24 | [DispId(2)]
25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
26 | [return: MarshalAs(UnmanagedType.Interface)]
27 | IMSScriptModule Add([MarshalAs(UnmanagedType.BStr), In] string Name, [MarshalAs(UnmanagedType.Struct), In, Optional] ref object Object);
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/IMSScriptProcedure.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Interop.MSScript {
5 |
6 | [Guid("70841C73-067D-11D0-95D8-00A02463AB28")]
7 | [ComImport(), InterfaceType(2), TypeLibType(4304)]
8 | public interface IMSScriptProcedure {
9 |
10 | [DispId(0)]
11 | string Name{ [DispId(0), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
12 |
13 | [DispId(100)]
14 | int NumArgs { [DispId(100), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
15 |
16 | [DispId(101)]
17 | bool HasReturnValue { [DispId(101), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
18 |
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/IMSScriptProcedures.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Runtime.InteropServices.CustomMarshalers;
5 |
6 | namespace Interop.MSScript {
7 |
8 | [Guid("70841C71-067D-11D0-95D8-00A02463AB28")]
9 | [ComImport(), InterfaceType(2), TypeLibType(4304)]
10 | public interface IMSScriptProcedures : IEnumerable {
11 |
12 | [DispId(0)]
13 | IMSScriptProcedure this[[MarshalAs(UnmanagedType.Struct), In] object Index] { [DispId(0), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
14 |
15 | [DispId(1)]
16 | int Count { [DispId(1), MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] get; }
17 |
18 | [TypeLibFunc((short)64)]
19 | [DispId(-4)]
20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
21 | [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(EnumeratorToEnumVariantMarshaler))]
22 | new IEnumerator GetEnumerator();
23 |
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/MSScriptControlConstants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Interop.MSScript {
5 |
6 | [Guid("AE311340-082C-11D0-95DE-00A02463AB28")]
7 | public abstract class MSScriptControlConstants {
8 | public const string GlobalModule = "Global";
9 | public const int NoTimeout = -1;
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/MSScriptControl_EventSink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace Interop.MSScript {
6 |
7 | [Guid("8B167D60-8605-11D0-ABCB-00A0C90FFFC0")]
8 | [ComImport, InterfaceType((short)2), TypeLibType((short)4112)]
9 | public interface IMSScriptControl_EventSink {
10 |
11 | [DispId(3000)]
12 | [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
13 | void Error();
14 |
15 | [DispId(3001)]
16 | [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
17 | void Timeout();
18 |
19 | }
20 |
21 |
22 | [ClassInterface(ClassInterfaceType.None)]
23 | [TypeLibType(TypeLibTypeFlags.FHidden)]
24 | class MSScriptControl_EventSink : IMSScriptControl_EventSink {
25 |
26 | public DScriptControlSource_ErrorEventHandler _ErrorDelegate;
27 | public DScriptControlSource_TimeoutEventHandler _TimeoutDelegate;
28 |
29 | internal MSScriptControl_EventSink() {
30 | _ErrorDelegate = null;
31 | _TimeoutDelegate = null;
32 | }
33 |
34 | public void Error() {
35 | if (_ErrorDelegate != null)
36 | _ErrorDelegate();
37 | }
38 |
39 | public void Timeout() {
40 | if (_TimeoutDelegate != null)
41 | _TimeoutDelegate();
42 | }
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/VbsConsole/Interop/ScriptControlStates.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Interop.MSScript {
3 |
4 | public enum ScriptControlStates {
5 | Initialized = 0,
6 | Connected = 1
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/VbsConsole/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ScriptRunner")]
9 | [assembly: AssemblyDescription("Vbs script runner")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Florent BREHERET")]
12 | [assembly: AssemblyProduct("ScriptRunner")]
13 | [assembly: AssemblyCopyright("Copyright © Florent BREHERET 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f3be12b1-267a-4553-ae6b-add7e23650c0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.1.0")]
36 | [assembly: AssemblyFileVersion("1.0.1.0")]
37 |
--------------------------------------------------------------------------------
/VbsConsole/ScriptModule.cs:
--------------------------------------------------------------------------------
1 | using Interop.MSScript;
2 | using System;
3 | using System.Reflection;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace vbsc {
7 |
8 | class ScriptModule {
9 |
10 | private IMSScriptModule _msc_module;
11 | private Type _msc_type;
12 |
13 | public ScriptModule(IMSScriptModule msc_module) {
14 | _msc_module = msc_module;
15 | _msc_type = msc_module.GetType();
16 | }
17 |
18 | public object Run(string procedure, object[] arguments) {
19 | object[] invokeArgs;
20 | if (arguments != null && arguments.Length != 0) {
21 | invokeArgs = new object[1 + arguments.Length];
22 | Array.Copy(arguments, 0, invokeArgs, 1, arguments.Length);
23 | } else {
24 | invokeArgs = new[] { procedure };
25 | }
26 | invokeArgs[0] = procedure;
27 | return _msc_type.InvokeMember("Run", BindingFlags.InvokeMethod, null, _msc_module, invokeArgs);
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VbsConsole/ScriptProcedure.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace vbsc {
3 |
4 | class ScriptProcedure {
5 |
6 | private readonly ScriptModule _module;
7 | private readonly string _name;
8 | private object[] _arguments;
9 |
10 | public ScriptProcedure(ScriptModule module, string name) {
11 | _module = module;
12 | _name = name;
13 | _arguments = new object[0];
14 | }
15 |
16 | public ScriptProcedure(ScriptModule module, string name, object[] args) {
17 | _module = module;
18 | _name = name;
19 | _arguments = args;
20 | }
21 |
22 | public string Name {
23 | get {
24 | return _name;
25 | }
26 | }
27 |
28 | public object[] Arguments {
29 | get {
30 | return _arguments;
31 | }
32 | set {
33 | _arguments = value;
34 | }
35 | }
36 |
37 | public object Run() {
38 | return _module.Run(_name, this.Arguments);
39 | }
40 |
41 | public bool HasArguments {
42 | get {
43 | return _arguments != null && _arguments.Length != 0;
44 | }
45 | }
46 |
47 | public override string ToString() {
48 | if (!this.HasArguments)
49 | return _name;
50 | if (_name.ToLower() == "onerror")
51 | return string.Concat(_name, "(\"", _arguments[0], "\", )");
52 | return string.Concat(_name, '(', _arguments.Join(',', 20), ')');
53 | }
54 |
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/VbsConsole/ScriptProcedures.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace vbsc {
4 |
5 | class ScriptProcedures : List {
6 |
7 | public ScriptProcedure ProcInitialize = null;
8 | public ScriptProcedure ProcTerminate = null;
9 | public ScriptProcedure ProcSetup = null;
10 | public ScriptProcedure ProcTearDown = null;
11 | public ScriptProcedure ProcOnError = null;
12 |
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/VbsConsole/ScriptResult.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using System;
3 |
4 | namespace vbsc {
5 |
6 | interface IScriptResult {
7 |
8 | Script Script { get; }
9 |
10 | bool Succeed { get; }
11 |
12 | string Source { get; }
13 |
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/VbsConsole/ScriptSuccees.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace vbsc {
4 |
5 | class ScriptSuccess : IScriptResult {
6 |
7 | private readonly Script _script;
8 | private readonly ScriptProcedure _procedure;
9 |
10 | public ScriptSuccess(Script script, ScriptProcedure procedure = null) {
11 | _script = script;
12 | _procedure = procedure;
13 | }
14 |
15 | public Script Script {
16 | get {
17 | return _script;
18 | }
19 | }
20 |
21 | public bool Succeed {
22 | get {
23 | return true;
24 | }
25 | }
26 |
27 | public string Source {
28 | get {
29 | if (_procedure == null)
30 | return string.Concat("in ", _script);
31 | return string.Concat(_procedure, " in ", _script);
32 | }
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/VbsConsole/TraceLine.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace vbsc {
3 |
4 | class TraceLine {
5 |
6 | public readonly Script Script;
7 | public readonly int LineNumber;
8 | public readonly string LineOfCode;
9 |
10 | public TraceLine(Script script, int line) {
11 | Script = script;
12 | LineNumber = line;
13 | LineOfCode = script.TextOriginal.GetLineAt(line);
14 | }
15 |
16 | public override string ToString() {
17 | return string.Format("at {0} line {1}\r\n {2}", this.Script.Path, this.LineNumber, this.LineOfCode);
18 | }
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/VbsConsole/WithParams.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace vbsc {
3 |
4 | struct WithParams {
5 | public string Params;
6 | public int Line;
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/clean-folders.py:
--------------------------------------------------------------------------------
1 |
2 | """Utility script to clean the project files and folders
3 | """
4 |
5 | DELETE_FOLDERS_PATTERNS = ['bin', 'obj']
6 | DELETE_FILES_PATTERNS = ['*.suo', '*.bak', '*.pyc']
7 |
8 | import sys, os, fnmatch, shutil
9 |
10 | __dir__ = os.path.dirname(os.path.realpath(__file__))
11 |
12 | def main():
13 | print __doc__
14 | print "Folders : " + ', '.join(DELETE_FOLDERS_PATTERNS)
15 | print "Files : " + ', '.join(DELETE_FILES_PATTERNS)
16 | print ""
17 | print "Start cleaning ..."
18 |
19 | for root_dir, folders, files in os.walk(__dir__):
20 |
21 | for del_dir in DELETE_FOLDERS_PATTERNS:
22 | for dirname in fnmatch.filter(folders, del_dir):
23 | dir_path = os.path.join(root_dir, dirname)
24 | print "rm %s" % dir_path
25 | shutil.rmtree(dir_path)
26 |
27 | for del_file in DELETE_FILES_PATTERNS:
28 | for filename in fnmatch.filter(files, del_file):
29 | file_path = os.path.join(root_dir, filename)
30 | print "rm %s" % file_path
31 | os.remove(file_path)
32 |
33 | print "\nDone"
34 |
35 | if __name__ == '__main__':
36 | main()
37 |
--------------------------------------------------------------------------------
/clean-registry.py:
--------------------------------------------------------------------------------
1 |
2 | """Utility script to clean the registry """
3 |
4 | # To run the script from the context menu with elevation:
5 | # [HKEY_CLASSES_ROOT\Python.File\shell\runas\command]
6 | # @="C:\Program Files (x86)\Python27\python.exe" -i "%1" %* runas
7 |
8 | # Additional modules:
9 | # pip install pywin32
10 |
11 | STARTSWITH_PROGID = "Selenium."
12 | STARTSWITH_GUID = "{0277FC34-FD1B-4616-BB19"
13 |
14 | import sys, os, io, sys, win32api, win32con
15 |
16 | __dir__ = os.path.dirname(os.path.realpath(__file__))
17 |
18 | HKCR = win32con.HKEY_CLASSES_ROOT
19 | HKLM = win32con.HKEY_LOCAL_MACHINE
20 | HKCU = win32con.HKEY_CURRENT_USER
21 | HKMAP = {HKCR:'HKCR', HKLM:'HKLM', HKCU:'HKCU'}
22 |
23 | VIEW32 = win32con.KEY_WOW64_32KEY | win32con.KEY_ALL_ACCESS
24 | VIEW64 = win32con.KEY_WOW64_64KEY | win32con.KEY_ALL_ACCESS
25 | VIEWMAP = {VIEW32:'32', VIEW64:''}
26 |
27 | def main():
28 | print __doc__
29 | print "Start cleaning registry ..."
30 | print ""
31 |
32 | for view in (VIEW64, VIEW32):
33 | hRoot = HKCR
34 | for subkey1 in [r'', r'TypeLib', r'CLSID', r'Interface', r'Record']:
35 | hKey = win32api.RegOpenKeyEx(hRoot, subkey1, 0, view)
36 | for subkey2, r, c, l in win32api.RegEnumKeyEx(hKey):
37 | if subkey2.startswith(STARTSWITH_GUID) or subkey2.startswith(STARTSWITH_PROGID):
38 | print '\\'.join((HKMAP[hRoot] + VIEWMAP[view], subkey1, subkey2)).replace('\\\\', '\\')
39 | try:
40 | win32api.RegDeleteTree(hKey, subkey2)
41 | except Exception as ex :
42 | print ' failed: %s' % ex.strerror
43 | win32api.RegCloseKey(hKey)
44 |
45 | print "\nDone"
46 |
47 | def elevate():
48 | import ctypes, win32com.shell.shell, win32event, win32process
49 | outpath = r'%s\%s.out' % (os.environ["TEMP"], os.path.basename(__file__))
50 | if ctypes.windll.shell32.IsUserAnAdmin():
51 | if os.path.isfile(outpath):
52 | sys.stderr = sys.stdout = open(outpath, 'w', 0)
53 | return
54 | with open(outpath, 'w+', 0) as outfile:
55 | hProc = win32com.shell.shell.ShellExecuteEx(lpFile=sys.executable, \
56 | lpVerb='runas', lpParameters=' '.join(sys.argv), fMask=64, nShow=0)['hProcess']
57 | while True:
58 | hr = win32event.WaitForSingleObject(hProc, 40)
59 | while True:
60 | line = outfile.readline()
61 | if not line: break
62 | sys.stdout.write(line)
63 | if hr != 0x102: break
64 | os.remove(outpath)
65 | sys.stderr = ''
66 | sys.exit(win32process.GetExitCodeProcess(hProc))
67 |
68 | if __name__ == '__main__':
69 | elevate()
70 | main()
71 |
--------------------------------------------------------------------------------
/smoke-tests.py:
--------------------------------------------------------------------------------
1 |
2 | """Basic tests to ensure all the browsers are launchable with the COM server
3 | """
4 |
5 | import sys, os, unittest, threading, time, multiprocessing, BaseHTTPServer
6 | from win32com import client #http://sourceforge.net/projects/pywin32/files/pywin32/
7 |
8 | SERVER_ADDRESS = ('127.0.0.1', 9393)
9 | SERVER_PAGE = """
10 |
11 |
12 | Title
13 |
14 |
15 | Test page
16 |
17 |
18 | """
19 |
20 | class Suite(unittest.TestCase):
21 |
22 | def test_list(self):
23 | lst = CreateObject("Selenium.List")
24 | for i in range(0, 10):
25 | lst.add(i)
26 | self.assertEqual(10, lst.Count)
27 |
28 | def test_firefox(self):
29 | self.assert_browser_display_page("Selenium.FirefoxDriver")
30 |
31 | def test_iedriver(self):
32 | self.assert_browser_display_page("Selenium.IEDriver")
33 |
34 | def test_chrome(self):
35 | self.assert_browser_display_page("Selenium.ChromeDriver")
36 |
37 | def test_opera(self):
38 | self.assert_browser_display_page("Selenium.OperaDriver")
39 |
40 | def test_phantomjs(self):
41 | self.assert_browser_display_page("Selenium.PhantomJSDriver")
42 |
43 | def assert_browser_display_page(self, progid):
44 | driver = CreateObject(progid)
45 | try:
46 | driver.get("http://%s:%s" % SERVER_ADDRESS)
47 | txt = driver.FindElementById('link').Text
48 | self.assertEqual("Test page", txt)
49 | finally:
50 | driver.quit
51 |
52 |
53 |
54 | def CreateObject(progid):
55 | return client.Dispatch(progid)
56 |
57 | def RunHTTPServer():
58 | server = BaseHTTPServer.HTTPServer(SERVER_ADDRESS, HTTPServerHandler)
59 | server.serve_forever()
60 |
61 | class HTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
62 |
63 | def handle(self):
64 | try:
65 | return BaseHTTPServer.BaseHTTPRequestHandler.handle(self)
66 | except: return
67 |
68 | def log_message(self, format, *args):
69 | return
70 |
71 | def do_GET(s):
72 | s.send_response(200)
73 | s.send_header('Content-type', 'text/html')
74 | s.end_headers()
75 | s.wfile.write(SERVER_PAGE)
76 |
77 |
78 | if __name__ == '__main__':
79 | print __doc__
80 | print "Start tests ...\n"
81 | server = multiprocessing.Process(target=RunHTTPServer)
82 | server.start()
83 | try:
84 | unittest.main()
85 | except SystemExit: pass
--------------------------------------------------------------------------------