Skip to content

Commit 02918c8

Browse files
committed
Fixed the Size and Point objects that were not accessible from VBScript
1 parent 7541a83 commit 02918c8

8 files changed

Lines changed: 100 additions & 39 deletions

File tree

Selenium.Tests/TS_Element.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void ShouldReturnIsEnabled() {
8080
public void ShouldReturnLocation() {
8181
var ele1 = driver.FindElementById("txt_div");
8282

83-
Point expected = new Point { X = 20, Y = 156 };
83+
Point expected = new Point(20, 156);
8484
Point actual = ele1.Location();
8585

8686
int diffX = Math.Abs(actual.X - expected.X);

Selenium/ComInterfaces/_Point.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

Selenium/ComInterfaces/_Size.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
}

Selenium/Selenium.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
<Reference Include="System.Xml" />
6464
</ItemGroup>
6565
<ItemGroup>
66+
<Compile Include="ComInterfaces\_Point.cs" />
67+
<Compile Include="ComInterfaces\_Size.cs" />
6668
<Compile Include="Errors\FileNotFoundError.cs" />
6769
<Compile Include="Internal\COMDisposable.cs" />
6870
<Compile Include="Internal\ProcessExt.cs" />

Selenium/Selenium.shfbproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@
5151
<Filter entryType="Class" fullName="Selenium.DictionaryItem.DictionaryItemEnumerator" filterName="DictionaryItem.DictionaryItemEnumerator" isExposed="False" />
5252
<Filter entryType="Class" fullName="Selenium.List.ListEnumerator" filterName="List.ListEnumerator" isExposed="False" />
5353
<Filter entryType="Class" fullName="Selenium.Logs" filterName="Logs" isExposed="False" />
54+
<Filter entryType="Structure" fullName="Selenium.Point" filterName="Point" isExposed="True">
55+
<Filter entryType="Method" fullName="Selenium.Point.ToString" filterName="ToString" isExposed="False" />
56+
</Filter>
5457
<Filter entryType="Class" fullName="Selenium.SeleniumError" filterName="SeleniumError" isExposed="False" />
5558
<Filter entryType="Class" fullName="Selenium.SeleniumException" filterName="SeleniumException" isExposed="False" />
59+
<Filter entryType="Structure" fullName="Selenium.Size" filterName="Size" isExposed="True">
60+
<Filter entryType="Method" fullName="Selenium.Size.ToString" filterName="ToString" isExposed="False" />
61+
</Filter>
5662
<Filter entryType="Enumeration" fullName="Selenium.Strategy" filterName="Strategy" isExposed="False" />
5763
</Filter>
5864
<Filter entryType="Namespace" fullName="Selenium.ComInterfaces" isExposed="False" />

Selenium/Struct/Point.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,17 @@ namespace Selenium {
88
/// <summary>
99
/// Point structure
1010
/// </summary>
11-
[Guid("0277FC34-FD1B-4616-BB19-ACE280CD7780")]
12-
[ComVisible(true)]
13-
[DebuggerDisplay("x = {X} y = {Y}")]
14-
public struct Point {
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 {
1515

16-
/// <summary>
17-
/// X value
18-
/// </summary>
19-
public int X;
20-
21-
/// <summary>
22-
/// Y value
23-
/// </summary>
24-
public int Y;
16+
private int _x, _y;
2517

2618
internal Point(Dictionary dict) {
2719
try {
28-
this.X = Convert.ToInt32(dict["x"]);
29-
this.Y = Convert.ToInt32(dict["y"]);
20+
_x = Convert.ToInt32(dict["x"]);
21+
_y = Convert.ToInt32(dict["y"]);
3022
} catch (Errors.KeyNotFoundError ex) {
3123
throw new DeserializeException(typeof(Point), ex);
3224
} catch (InvalidCastException ex) {
@@ -40,17 +32,32 @@ internal Point(Dictionary dict) {
4032
/// <param name="x"></param>
4133
/// <param name="y"></param>
4234
public Point(int x, int y) {
43-
this.X = x;
44-
this.Y = y;
35+
_x = x;
36+
_y = y;
37+
}
38+
39+
/// <summary>
40+
/// X
41+
/// </summary>
42+
public int X {
43+
get { return _x; }
44+
}
45+
46+
/// <summary>
47+
/// Y
48+
/// </summary>
49+
public int Y {
50+
get { return _y; }
4551
}
4652

4753
/// <summary>
4854
/// Returns the text representaton of this instance
4955
/// </summary>
5056
/// <returns></returns>
5157
public override string ToString() {
52-
return string.Format(@"{{x={0} y={1}}}", this.X, this.Y);
58+
return string.Format(@"{{x={0} y={1}}}", _x, _y);
5359
}
5460

5561
}
62+
5663
}

Selenium/Struct/Size.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,56 @@ namespace Selenium {
88
/// <summary>
99
/// Size structure
1010
/// </summary>
11-
[Guid("0277FC34-FD1B-4616-BB19-7E2EBB6C82E9")]
12-
[ComVisible(true)]
13-
[DebuggerDisplay("width = {Width} height = {Height}")]
14-
public struct Size {
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 {
1515

16-
/// <summary>
17-
///
18-
/// </summary>
19-
public int Width;
20-
21-
/// <summary>
22-
///
23-
/// </summary>
24-
public int Height;
16+
private int _width, _height;
2517

2618
/// <summary>
2719
/// Get the size
2820
/// </summary>
2921
/// <param name="width"></param>
3022
/// <param name="height"></param>
3123
public Size(int width, int height) {
32-
this.Width = width;
33-
this.Height = height;
24+
_width = width;
25+
_height = height;
3426
}
3527

3628
internal Size(Dictionary dict) {
3729
try {
38-
this.Width = Convert.ToInt32(dict["width"]);
39-
this.Height = Convert.ToInt32(dict["height"]);
30+
_width = Convert.ToInt32(dict["width"]);
31+
_height = Convert.ToInt32(dict["height"]);
4032
} catch (Errors.KeyNotFoundError ex) {
4133
throw new DeserializeException(typeof(Size), ex);
4234
} catch (InvalidCastException ex) {
4335
throw new DeserializeException(typeof(Size), ex);
4436
}
4537
}
4638

39+
/// <summary>
40+
/// Width
41+
/// </summary>
42+
public int Width {
43+
get { return _width; }
44+
}
45+
46+
/// <summary>
47+
/// Height
48+
/// </summary>
49+
public int Height {
50+
get { return _height; }
51+
}
52+
4753
/// <summary>
4854
/// Returns the text representaton of this instance.
4955
/// </summary>
5056
/// <returns></returns>
5157
public override string ToString() {
52-
return string.Format(@"{{width={0} height={1}}}", this.Width, this.Height);
58+
return string.Format(@"{{width={0} height={1}}}", _width, _height);
5359
}
5460

5561
}
62+
5663
}

SeleniumBasicSetup.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@
4848
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-6E0522EA435E}', '_Application', '{00020420-0000-0000-C000-000000000046}');
4949
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-74F5D5680428}', '_Timeouts', '{00020420-0000-0000-C000-000000000046}');
5050
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-7C9763568492}', '_WebElements', '{00020420-0000-0000-C000-000000000046}');
51+
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-7E2EBB6C82E9}', '_Size', '{00020420-0000-0000-C000-000000000046}');
5152
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-8B145197B76C}', '_WebElement', '{00020420-0000-0000-C000-000000000046}');
5253
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-A398E67A519B}', '_DictionaryItem', '{00020424-0000-0000-C000-000000000046}');
5354
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-A3DE5685A27E}', '_By', '{00020420-0000-0000-C000-000000000046}');
55+
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-ACE280CD7780}', '_Point', '{00020420-0000-0000-C000-000000000046}');
5456
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-B51CB7C5A694}', '_Alert', '{00020420-0000-0000-C000-000000000046}');
5557
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-B825A6BF9610}', '_Table', '{00020424-0000-0000-C000-000000000046}');
5658
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-BBE48A6D09DB}', '_Actions', '{00020420-0000-0000-C000-000000000046}');
@@ -66,7 +68,5 @@
6668
RegInterface(lib, '{0277FC34-FD1B-4616-BB19-FFD6FAEF290A}', '_TouchScreen', '{00020420-0000-0000-C000-000000000046}');
6769

6870
RegRecord(lib, '{0277FC34-FD1B-4616-BB19-300DAA508541}', 'Selenium.Strategy');
69-
RegRecord(lib, '{0277FC34-FD1B-4616-BB19-7E2EBB6C82E9}', 'Selenium.Size');
70-
RegRecord(lib, '{0277FC34-FD1B-4616-BB19-ACE280CD7780}', 'Selenium.Point');
7171
RegRecord(lib, '{0277FC34-FD1B-4616-BB19-B342CE81CB2A}', 'Selenium.MouseButton');
7272
RegRecord(lib, '{0277FC34-FD1B-4616-BB19-C724C5135B6E}', 'Selenium.CacheState');

0 commit comments

Comments
 (0)