Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Set reference in VBA (64bit) #263

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.vs
References
packages
bin
obj
Xlbin
Sandcastle/Help
Sandcastle/COMs.xml
*.msi
*.exe
*.log
*.bak
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Author : Florent BREHERET
Website : https://github.com/florentbr/SeleniumBasic

V3+ modifications : zc2
Website : https://github.com/zc2com/SeleniumBasic


Third party softwares:

Selenium - Software Freedom Conservancy
Expand All @@ -16,6 +20,12 @@ Third party softwares:
http://phantomjs.org/


v3.0.0.1 (2022/11/11)
===============================================================================
* Added support of Gecko webdriver and modern API endpoints
* Added partial support of the ShadowRoot
* Built in 64 bit assembly

v2.0.9.0 (2016/03/02)
===============================================================================
* Updated examples
Expand Down
66 changes: 66 additions & 0 deletions Sandcastle/COMdescrToXML.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
BEGIN {
print "<?xml version=\"1.0\"?>"
print "<doc>"
print " <assembly>"
print " <name>Selenium</name>"
print " </assembly>"
print " <members>"
}

function TranslateType( par ) {
#print par
gsub(/^\s+/,"",par)
gsub(/\s.+$/,"",par)
gsub(/^\[MarshalAs\(UnmanagedType.Struct\)(, In)?\]/,"",par)
gsub(/^By/, "Selenium.By", par)
gsub(/^Strategy/,"Selenium.Strategy",par)
gsub(/^WebEleme/,"Selenium.WebEleme",par)
gsub(/^string/, "System.String", par)
gsub(/^object/, "System.Object", par)
gsub(/^bool/, "System.Boolean", par)
gsub(/^double/, "System.Double", par)
gsub(/^float/, "System.Single", par)
gsub(/^int/, "System.Int32", par)
gsub(/^short/, "System.Int16", par)
return par
}

{
if( match($0,/Description\("(.+?)"\)/,d) ) {
descr = d[1]
gsub("<","\\&lt;",descr)
gsub(">","\\&gt;",descr)
match(FILENAME,/(_[A-Z][A-z]+)\.cs/,f)
mn = ""
getline NL
if( match(NL,/\s([A-Z][A-z]+)\((.*)\);$/,m) ) {
method = m[1]
split(m[2],pars,",")
ps = ""
for( pi in pars ) {
par = TranslateType( pars[pi] )
ps = ps ? ps "," par : par
}
if( ps ) ps = "(" ps ")"
mn = "M:Selenium.ComInterfaces." f[1] "." method ps
} else
if( match(NL,/\s([A-Z][A-z]+)\s*{\s*[gs]et/,m) ) {
mn = "P:Selenium.ComInterfaces." f[1] "." m[1]
} else
if( match(NL,/this\[([a-z]+) [A-z]+\]/,m) ) {
mn = "P:Selenium.ComInterfaces." f[1] ".Item(" TranslateType( m[1] ) ")"
}
if( mn ) {
print " <member name=\"" mn "\">"
print " <summary>"
print " " descr
print " </summary>"
print " </member>"
}
}
}

END {
print " </members>"
print "</doc>"
}
99 changes: 99 additions & 0 deletions Sandcastle/SeleniumBasic.shfbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import the common properties to support NuGet restore -->
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<!-- The configuration and platform will be used to determine which assemblies to include from solution and
project documentation sources -->
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{f5d9ebff-8b71-4ca9-8357-36c7acef4147}</ProjectGuid>
<SHFBSchemaVersion>2017.9.26.0</SHFBSchemaVersion>
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName>
<RootNamespace>Documentation</RootNamespace>
<Name>Documentation</Name>
<!-- SHFB properties -->
<FrameworkVersion>.NET Framework 4.0</FrameworkVersion>
<OutputPath>Help\</OutputPath>
<HtmlHelpName>SeleniumBasic</HtmlHelpName>
<Language>en-US</Language>
<HelpFileFormat>HtmlHelp1</HelpFileFormat>
<SyntaxFilters>Visual Basic, Visual Basic Usage</SyntaxFilters>
<PresentationStyle>VS2013</PresentationStyle>
<CleanIntermediates>True</CleanIntermediates>
<KeepLogFile>True</KeepLogFile>
<DisableCodeBlockComponent>False</DisableCodeBlockComponent>
<IndentHtml>False</IndentHtml>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<SaveComponentCacheCapacity>100</SaveComponentCacheCapacity>
<DocumentationSources>
<DocumentationSource sourceFile="..\Selenium\Selenium.csproj" />
<DocumentationSource sourceFile="..\Selenium\bin\x64\Debug\Selenium.xml" />
<DocumentationSource sourceFile="..\Selenium\bin\x64\Debug\Selenium.dll" />
<DocumentationSource sourceFile="COMs.xml" />
</DocumentationSources>
<MissingTags>None</MissingTags>
<HelpTitle>SeleniumBasic</HelpTitle>
<HelpFileVersion>1.0.0.0</HelpFileVersion>
<NamingMethod>MemberName</NamingMethod>
<ContentPlacement>AboveNamespaces</ContentPlacement>
<RootNamespaceContainer>False</RootNamespaceContainer>
<NamespaceGrouping>False</NamespaceGrouping>
<MaximumGroupParts>2</MaximumGroupParts>
<Preliminary>False</Preliminary>
<SdkLinkTarget>Blank</SdkLinkTarget>
<VisibleItems>ExplicitInterfaceImplementations, InheritedMembers, PublicCompilerGenerated, NonBrowsable</VisibleItems>
<PlugInConfigurations>
</PlugInConfigurations>
<ApiFilter>
<Filter entryType="Namespace" fullName="Interop" isExposed="False" />
<Filter entryType="Namespace" fullName="Interop.Excel" isExposed="False" />
<Filter entryType="Namespace" fullName="Selenium" isExposed="True">
<Filter entryType="Class" fullName="Selenium.NamespaceDoc" filterName="NamespaceDoc" isExposed="False" />
</Filter>
<Filter entryType="Namespace" fullName="Selenium.Internal" isExposed="False" />
<Filter entryType="Namespace" fullName="Selenium.Serializer" isExposed="False" />
<Filter entryType="Namespace" fullName="Selenium.Zip" isExposed="False" />
</ApiFilter>
<SourceCodeBasePath>..\Selenium\</SourceCodeBasePath>
<WarnOnMissingSourceContext>False</WarnOnMissingSourceContext>
<ProjectSummary>SeleniumBasic - A Selenium based browser automation framework for VB.Net, Visual Basic Applications and VBScript</ProjectSummary>
<NamespaceSummaries>
<NamespaceSummaryItem name="Selenium" isDocumented="True">All public methods and properties. Some of them available only from a .NET (i.e. not via COM). To know which are available via COM refer to a corresponding COM interface name. If a method listed as a class member but not a member of a corresponding interface, the method won't be available via COM. Methods with an "S" icon are static and surely not available via COM. However, look for a similar method in the "Explicit Interface Implementations" section.</NamespaceSummaryItem>
<NamespaceSummaryItem name="Selenium.ComInterfaces" isDocumented="True">Only methods of those interfaces are available via COM (Component Object Model) from VBScript, etc.</NamespaceSummaryItem>
</NamespaceSummaries>
<HtmlHelp1xCompilerPath>C:\Program Files (x86)\HTML Help Workshop\</HtmlHelp1xCompilerPath>
</PropertyGroup>
<!-- There are no properties for these groups. AnyCPU needs to appear in order for Visual Studio to perform
the build. The others are optional common platform types that may appear. -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
</PropertyGroup>
<!-- Import the common build targets during NuGet restore because before the packages are being installed, $(SHFBROOT) is not set yet -->
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="'$(MSBuildRestoreSessionId)' != ''" />
<!-- Import the SHFB build targets during build -->
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" Condition="'$(MSBuildRestoreSessionId)' == ''" />
<!-- The pre-build and post-build event properties must appear *after* the targets file import in order to be
evaluated correctly. -->
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>gawk -f COMdescrToXML.awk ../Selenium/ComInterfaces/*.cs &gt;COMs.xml
</PostBuildEvent>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
</Project>
Binary file modified Scripts/StartEdge.vbs
Binary file not shown.
100 changes: 80 additions & 20 deletions Selenium.Tests/Internals/BaseBrowsers.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,114 @@
using NUnit.Framework;
using System;

namespace Selenium.Tests.Internals {

using System.Diagnostics;
using OneTimeSetUp=NUnit.Framework.TestFixtureSetUpAttribute;
using OneTimeTearDown=NUnit.Framework.TestFixtureTearDownAttribute;

namespace Selenium.Tests.Internals
{
public enum Browser {
Firefox, Chrome, Opera, IE, PhantomJS
unknown, Firefox, Chrome, Opera, IE, PhantomJS, Gecko, Edge
}

abstract class BaseBrowsers {

public readonly object Fixture;

public static bool remote_driver = false;
public readonly object FixtureParam;
private Process driver_process;
protected WebDriver driver;
protected Keys Keys = new Keys();
protected By By = new By();

public BaseBrowsers() : this(GetBrowserFromCategory()) {
}

public BaseBrowsers(Browser browser) {
WebServer.StartServer(@"..\..\Pages");
this.driver = GetBrowserInstance(browser);
if( remote_driver ) {
this.driver = GetRemotelyStartedDriver(browser);
} else {
this.driver = GetDriverInstance(browser);
}
this.driver.BaseUrl = WebServer.BaseUri;
this.Fixture = browser;
this.FixtureParam = browser;
}

[OneTimeSetUp]
public void TestFixtureSetUp() {
}

[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown() {
driver.Quit();
if( driver_process != null && !driver_process.HasExited ) {
driver_process.Kill();
}
}

private static Browser GetBrowserFromCategory() {
if( NUnit.Core.TestExecutionContext.CurrentContext.CurrentTest.Categories.Contains("Edge") )
return Browser.Edge;
return Browser.unknown;
}

private string GetBrowserTypeLib(Browser browser) {
switch (browser) {
case Browser.Firefox: return "Selenium.FirefoxDriver";
case Browser.Chrome: return "Selenium.ChromeDriver";
case Browser.Opera: return "Selenium.OperaDriver";
case Browser.IE: return "Selenium.IEDriver";
case Browser.Gecko: return "Selenium.GeckoDriver";
case Browser.Firefox: return "Selenium.FirefoxDriver";
case Browser.Edge: return "Selenium.EdgeDriver";
case Browser.Chrome: return "Selenium.ChromeDriver";
case Browser.Opera: return "Selenium.OperaDriver";
case Browser.IE: return "Selenium.IEDriver";
case Browser.PhantomJS: return "Selenium.PhantomJSDriver";
}
throw new Exception("Browser not supported: " + browser.ToString());
}

private WebDriver GetBrowserInstance(Browser browser) {
private WebDriver GetDriverInstance(Browser browser) {
switch (browser) {
case Browser.Firefox: return new Selenium.FirefoxDriver();
case Browser.Chrome: return new Selenium.ChromeDriver();
case Browser.Opera: return new Selenium.OperaDriver();
case Browser.IE: return new Selenium.IEDriver();
case Browser.Gecko: return new Selenium.GeckoDriver();
case Browser.Firefox:
Selenium.FirefoxDriver ffd = new Selenium.FirefoxDriver();
ffd.SetBinary( @"C:\Utils\Firefox46\firefox.exe" );
return ffd;
case Browser.Edge: return new Selenium.EdgeDriver();
case Browser.Chrome: return new Selenium.ChromeDriver();
case Browser.Opera: return new Selenium.OperaDriver();
case Browser.IE: return new Selenium.IEDriver();
case Browser.PhantomJS: return new Selenium.PhantomJSDriver();
}
throw new Exception("Browser not supported: " + browser.ToString());
}

private WebDriver GetRemotelyStartedDriver(Browser browser) {
ProcessStartInfo p_info = new ProcessStartInfo();
p_info.UseShellExecute = true;
p_info.CreateNoWindow = false;
p_info.WindowStyle = ProcessWindowStyle.Normal;
switch (browser) {
case Browser.Gecko:
p_info.FileName = "geckodriver.exe";
p_info.Arguments = "-vv";
break;
case Browser.Chrome:
p_info.FileName = "chromedriver.exe";
p_info.Arguments = "--port=4444 --verbose";
break;
case Browser.Edge:
p_info.FileName = "edgedriver.exe";
p_info.Arguments = "--port=4444 --verbose";
break;
default: throw new Exception("Browser not supported: " + browser.ToString());
}
try {
driver_process = Process.Start(p_info);
NUnit.Framework.Assert.False( driver_process.HasExited, "Driver process cannot start: " + browser.ToString() );
WebDriver s = new Selenium.WebDriver();
s.StartRemotely( "http://localhost:4444/", browser.ToString().ToLower() );
return s;
} catch( Exception e ) {
NUnit.Framework.Assert.Fail( "Thrown exception: " + e.Message );
}
return null;
}
}

}
8 changes: 4 additions & 4 deletions Selenium.Tests/Internals/BaseExcel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Globalization;
using System.Threading;
using TestFixtureSetUp = NUnit.Framework.TestFixtureSetUpAttribute;
using TestFixtureTearDown = NUnit.Framework.TestFixtureTearDownAttribute;
using OneTimeSetUp=NUnit.Framework.TestFixtureSetUpAttribute;
using OneTimeTearDown=NUnit.Framework.TestFixtureTearDownAttribute;

namespace Selenium.Tests.Internals {

Expand All @@ -14,7 +14,7 @@ abstract class BaseExcel {
protected COM worksheets;
protected COM worksheet;

[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp() {

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Expand All @@ -28,7 +28,7 @@ public void TestFixtureSetUp() {
worksheet = workbook.get("ActiveSheet");
}

[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown() {
workbook.invoke("Close", false, Type.Missing, Type.Missing);
excel.invoke("Quit");
Expand Down
2 changes: 1 addition & 1 deletion Selenium.Tests/Internals/IgnoreFixtureAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public IgnoreFixtureAttribute(object fixture, string reason) {

public void BeforeTest(TestDetails testDetails) {
BaseBrowsers tb = testDetails.Fixture as BaseBrowsers;
if (tb != null && _fixture.Equals(tb.Fixture))
if (tb != null && _fixture.Equals(tb.FixtureParam))
A.Ignore(string.Format("{0}: {1}", _fixture, _reason));
}

Expand Down
2 changes: 1 addition & 1 deletion Selenium.Tests/Internals/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Selenium.Tests.Internals {

public class WebServer {

public static string BaseUri = @"http://localhost:9328";
public static string BaseUri = @"http://localhost:19328";

static WebServer _server = null;

Expand Down
Loading