Skip to content

Commit 6d352ef

Browse files
rathr1rathr1
authored andcommitted
Using SeleniumExtras.PageObjects
1 parent 0c53733 commit 6d352ef

7 files changed

Lines changed: 61 additions & 43 deletions

File tree

SeleniumWebdriver/BaseClasses/PageBase.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using OpenQA.Selenium;
7-
using OpenQA.Selenium.Support.PageObjects;
7+
using SeleniumExtras.PageObjects;
88
using SeleniumWebdriver.ComponentHelper;
99

1010
namespace SeleniumWebdriver.BaseClasses
@@ -13,12 +13,13 @@ public class PageBase
1313
{
1414
private IWebDriver driver;
1515

16-
//[FindsBy(How = How.LinkText,Using = "Home")]
17-
private IWebElement HomeLink => driver.FindElement(By.LinkText("Home"));
16+
[FindsBy(How = How.LinkText,Using = "Home")]
17+
private IWebElement HomeLink;
18+
//private IWebElement HomeLink => driver.FindElement(By.LinkText("Home"));
1819

1920
public PageBase(IWebDriver _driver)
2021
{
21-
//PageFactory.InitElements(_driver,this);
22+
PageFactory.InitElements(_driver,this);
2223
this.driver = _driver;
2324
}
2425

SeleniumWebdriver/PageObject/BugDetail.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using OpenQA.Selenium;
7-
using OpenQA.Selenium.Support.PageObjects;
7+
using SeleniumExtras.PageObjects;
88
using SeleniumWebdriver.BaseClasses;
99
using SeleniumWebdriver.ComponentHelper;
1010
using SeleniumWebdriver.Settings;
@@ -14,26 +14,32 @@ namespace SeleniumWebdriver.PageObject
1414
public class BugDetail : PageBase
1515
{
1616
private IWebDriver driver;
17-
17+
1818
#region WebElement
1919

20-
//[FindsBy(How = How.Id, Using = "bug_severity")]
21-
private IWebElement SeverityDropDown => driver.FindElement(By.Id("bug_severity"));
20+
[FindsBy(How = How.Id, Using = "bug_severity")]
21+
private IWebElement SeverityDropDown;
22+
//private IWebElement SeverityDropDown => driver.FindElement(By.Id("bug_severity"));
2223

23-
// [FindsBy(How = How.Id,Using = "rep_platform")]
24-
private IWebElement Hardware => driver.FindElement(By.Id("rep_platform"));
24+
[FindsBy(How = How.Id,Using = "rep_platform")]
25+
private IWebElement Hardware;
26+
//private IWebElement Hardware => driver.FindElement(By.Id("rep_platform"));
2527

26-
//[FindsBy(How = How.Id, Using = "op_sys")]
27-
private IWebElement OpSys => driver.FindElement(By.Id("op_sys"));
28+
[FindsBy(How = How.Id, Using = "op_sys")]
29+
private IWebElement OpSys;
30+
//private IWebElement OpSys => driver.FindElement(By.Id("op_sys"));
2831

29-
//[FindsBy(How = How.Id, Using = "short_desc")]
30-
private IWebElement ShortDesc => driver.FindElement(By.Id("short_desc"));
32+
[FindsBy(How = How.Id, Using = "short_desc")]
33+
private IWebElement ShortDesc;
34+
//private IWebElement ShortDesc => driver.FindElement(By.Id("short_desc"));
3135

32-
// [FindsBy(How = How.Id, Using = "comment")]
33-
private IWebElement Comment => driver.FindElement(By.Id("comment"));
36+
[FindsBy(How = How.Id, Using = "comment")]
37+
private IWebElement Comment;
38+
//private IWebElement Comment => driver.FindElement(By.Id("comment"));
3439

35-
//[FindsBy(How = How.Id, Using = "commit")]
36-
private IWebElement Commit => driver.FindElement(By.Id("commit"));
40+
[FindsBy(How = How.Id, Using = "commit")]
41+
private IWebElement Commit;
42+
//private IWebElement Commit => driver.FindElement(By.Id("commit"));
3743
#endregion
3844

3945
public BugDetail(IWebDriver _driver) : base(_driver)

SeleniumWebdriver/PageObject/EnterBug.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using OpenQA.Selenium;
7-
using OpenQA.Selenium.Support.PageObjects;
7+
using SeleniumExtras.PageObjects;
88
using SeleniumWebdriver.BaseClasses;
99
using SeleniumWebdriver.ComponentHelper;
1010
using SeleniumWebdriver.Settings;
@@ -16,8 +16,9 @@ public class EnterBug : PageBase
1616
private IWebDriver driver;
1717
#region WenElement
1818

19-
//[FindsBy(How = How.LinkText, Using = "Testng")]
20-
private IWebElement Testng => driver.FindElement(By.LinkText("Testng"));
19+
[FindsBy(How = How.LinkText, Using = "Testng")]
20+
private IWebElement Testng;
21+
//private IWebElement Testng => driver.FindElement(By.LinkText("Testng"));
2122

2223
#endregion
2324

SeleniumWebdriver/PageObject/HomePage.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Threading.Tasks;
66
using Microsoft.VisualStudio.TestTools.UnitTesting;
77
using OpenQA.Selenium;
8-
using OpenQA.Selenium.Support.PageObjects;
8+
using SeleniumExtras.PageObjects;
99
using SeleniumWebdriver.BaseClasses;
1010
using SeleniumWebdriver.ComponentHelper;
1111
using SeleniumWebdriver.Settings;
@@ -17,15 +17,18 @@ public class HomePage : PageBase
1717
private IWebDriver driver;
1818
#region WebElement
1919

20-
//[FindsBy(How = How.Id, Using = "quicksearch_main")]
21-
private IWebElement QuickSearchTextBox => driver.FindElement(By.Id("quicksearch_main"));
20+
[FindsBy(How = How.Id, Using = "quicksearch_main")]
21+
private IWebElement QuickSearchTextBox;
22+
//private IWebElement QuickSearchTextBox => driver.FindElement(By.Id("quicksearch_main"));
2223

23-
//[FindsBy(How = How.Id, Using = "find")]
24-
//[CacheLookup]
25-
private IWebElement QuickSearchBtn => driver.FindElement(By.Id("find"));
24+
[FindsBy(How = How.Id, Using = "find")]
25+
[CacheLookup]
26+
private IWebElement QuickSearchBtn;
27+
//private IWebElement QuickSearchBtn => driver.FindElement(By.Id("find"));
2628

27-
//[FindsBy(How = How.LinkText, Using = "File a Bug")]
28-
private IWebElement FileABugLink => driver.FindElement(By.LinkText("File a Bug"));
29+
[FindsBy(How = How.LinkText, Using = "File a Bug")]
30+
private IWebElement FileABugLink;
31+
//private IWebElement FileABugLink => driver.FindElement(By.LinkText("File a Bug"));
2932

3033
#endregion
3134

SeleniumWebdriver/PageObject/LoginPage.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using OpenQA.Selenium;
7-
using OpenQA.Selenium.Support.PageObjects;
7+
using SeleniumExtras.PageObjects;
88
using SeleniumWebdriver.BaseClasses;
99
using SeleniumWebdriver.ComponentHelper;
1010
using SeleniumWebdriver.Settings;
@@ -17,19 +17,22 @@ public class LoginPage : PageBase
1717

1818

1919
#region WebElement
20-
//[FindsBy(How = How.Id, Using = "Bugzilla_login")]
21-
private IWebElement LoginTextBox => driver.FindElement(By.Id("Bugzilla_login"));
22-
23-
//[FindsBy(How = How.Id, Using = "Bugzilla_password")]
24-
private IWebElement PassTextBox => driver.FindElement(By.Id("Bugzilla_password"));
25-
26-
//[FindsBy(How = How.Id, Using = "log_in")]
27-
//[CacheLookup]
28-
private IWebElement LoginButton => driver.FindElement(By.Id ("log_in"));
29-
30-
// [FindsBy(How = How.LinkText, Using = "Home")]
31-
32-
private IWebElement HomeLink => driver.FindElement(By.LinkText("Home"));
20+
[FindsBy(How = How.Id, Using = "Bugzilla_login")]
21+
private IWebElement LoginTextBox;
22+
//private IWebElement LoginTextBox => driver.FindElement(By.Id("Bugzilla_login"));
23+
24+
[FindsBy(How = How.Id, Using = "Bugzilla_password")]
25+
private IWebElement PassTextBox;
26+
//private IWebElement PassTextBox => driver.FindElement(By.Id("Bugzilla_password"));
27+
28+
[FindsBy(How = How.Id, Using = "log_in")]
29+
[CacheLookup]
30+
private IWebElement LoginButton;
31+
//private IWebElement LoginButton => driver.FindElement(By.Id ("log_in"));
32+
33+
[FindsBy(How = How.LinkText, Using = "Home")]
34+
private IWebElement HomeLink;
35+
//private IWebElement HomeLink => driver.FindElement(By.LinkText("Home"));
3336

3437

3538
#endregion

SeleniumWebdriver/SeleniumWebdriver.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
<Reference Include="Protractor, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
5757
<HintPath>..\packages\Protractor.0.11.0\lib\net40\Protractor.dll</HintPath>
5858
</Reference>
59+
<Reference Include="SeleniumExtras.PageObjects, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
60+
<HintPath>..\packages\DotNetSeleniumExtras.PageObjects.3.11.0\lib\net45\SeleniumExtras.PageObjects.dll</HintPath>
61+
</Reference>
5962
<Reference Include="SeleniumExtras.WaitHelpers, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
6063
<HintPath>..\packages\DotNetSeleniumExtras.WaitHelpers.3.11.0\lib\net45\SeleniumExtras.WaitHelpers.dll</HintPath>
6164
</Reference>

SeleniumWebdriver/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="DotNetSeleniumExtras.PageObjects" version="3.11.0" targetFramework="net452" />
34
<package id="DotNetSeleniumExtras.WaitHelpers" version="3.11.0" targetFramework="net452" />
45
<package id="ExcelDataReader" version="3.3.0" targetFramework="net452" />
56
<package id="ExcelDataReader.DataSet" version="3.3.0" targetFramework="net452" />

0 commit comments

Comments
 (0)