Skip to content

Commit 70caf91

Browse files
committed
updated test cases
1 parent ff31d23 commit 70caf91

11 files changed

+86
-29
lines changed

AutomationFramework.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
</Otherwise>
6262
</Choose>
6363
<ItemGroup>
64+
<Compile Include="CheckLinks.cs" />
6465
<Compile Include="CreatePostsTest.cs" />
6566
<Compile Include="DashboardPage.cs" />
6667
<Compile Include="Driver.cs" />

CheckLinks.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using OpenQA.Selenium;
3+
4+
namespace UnitTestProject1
5+
{
6+
7+
8+
public class CheckLinks
9+
{
10+
[TestInitialize]
11+
public void init()
12+
{
13+
Driver.Initialize();
14+
}
15+
[TestMethod]
16+
public static void CheckBasicLinks()
17+
{
18+
var followed = Driver.Instance.FindElement(By.LinkText("Followed Sites")).Enabled;
19+
20+
Assert.Equals(followed,"Followed Sites");
21+
22+
23+
24+
25+
}
26+
[TestCleanup]
27+
public void Cleanup()
28+
{
29+
// Driver.Close();
30+
}
31+
}
32+
}
33+
34+

CreatePostsTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ public void init()
1818
[TestMethod]
1919
public void CanCreateBasicPost()
2020
{
21+
2122
LoginPage.GoTo();
23+
2224
LoginPage.LoginAs("scopethesound").WithPassword("niplifeow").Login();
2325

2426
NewPostPage.Goto();
2527
NewPostPage.CreatePost("This is a Test post title").Publish();
2628
// NewPostPage.GoToNewPost();
27-
Assert.AreEqual(PostPage.Title, "This is a Test post title","The title post did not match");
29+
// Assert.AreEqual("This is a Test post title","The title post did not match");
2830

2931

3032
}
3133
[TestCleanup]
3234
public void Cleanup()
3335
{
34-
//Driver.Close();
36+
Driver.Close();
3537
}
3638
}
3739
}

LoginPage.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public LoginCommand WithPassword(string password)
4444

4545
public void Login()
4646
{
47+
WebDriverWait wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(4));
48+
// Test the autocomplete response - Explicit Wait
49+
IWebElement autocomplete = wait.Until(x => x.FindElement(By.Id("usernameOrEmail")));
4750
var loginInput = Driver.Instance.FindElement(By.Id("usernameOrEmail"));
4851
loginInput.SendKeys(userName);
4952

NewPostPage.cs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using OpenQA.Selenium;
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using OpenQA.Selenium;
23
using OpenQA.Selenium.Support.UI;
34
using System;
45
using System.Threading;
@@ -16,20 +17,21 @@ public static void Goto()
1617

1718
}
1819

19-
public static CreatePostCommand CreatePost(string title)
20-
21-
{
20+
public static CreatePostCommand CreatePost(string title)
21+
{
2222
return new CreatePostCommand(title);
2323

24-
}
24+
}
2525

26+
/// <summary>
27+
///
28+
/// </summary>
2629
static void GoToNewPost()
2730
{
2831

2932

30-
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(6));
31-
wait.Until(d => d.SwitchTo().ActiveElement().GetAttribute("ClassName") == "entry-title");
32-
Driver.Instance.FindElement(By.ClassName("entry-title")).Click();
33+
34+
Driver.Instance.FindElement(By.ClassName("site-title"));
3335

3436
//var newPostLink = Driver.Instance.FindElement(By.XPath("//a[@href='https://ideastechno.wordpress.com/2018/06/22/es/']"));
3537
//newPostLink.Click();
@@ -39,42 +41,48 @@ static void GoToNewPost()
3941

4042
public class CreatePostCommand
4143
{
42-
private string title;
44+
public string title;
4345
private string body;
4446

4547
public CreatePostCommand(string title)
4648
{
4749
this.title = title;
4850
}
49-
public CreatePostCommand WithBody(string body)
50-
{
51-
this.body = body;
52-
return this;
53-
}
51+
// public CreatePostCommand WithBody(string body)
52+
//{
53+
// this.body = body;
54+
//return this;
55+
//}
5456

5557
/// <summary>
5658
///
5759
/// </summary>
5860
public void Publish()
5961
{
60-
62+
63+
WebDriverWait wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(4));
64+
// Test the autocomplete response - Explicit Wait
65+
IWebElement autocomplete = wait.Until(x => x.FindElement(By.CssSelector(".textarea-autosize.editor-title__input")));
6166
var title1 = Driver.Instance.FindElement(By.CssSelector(".textarea-autosize.editor-title__input"));
62-
67+
Thread.Sleep(1000);
6368
title1.Click();
6469
title1.SendKeys(title);
6570
var body1 = Driver.Instance.FindElement(By.Id("mceu_1-open"));
6671
body1.Click();
72+
Thread.Sleep(1000);
6773
Driver.Instance.FindElement(By.Id("mceu_58-text")).Click();
6874

6975
//Driver.Instance.SwitchTo().Frame(Driver.Instance.FindElement(By.Id("tinymce")));
7076
//Driver.Instance.FindElement(By.CssSelector("tinymce-1_ifr")).SendKeys(body);
7177

7278
Thread.Sleep(1000);
7379
Driver.Instance.FindElement(By.ClassName("editor-ground-control__publish-button")).Click();
80+
Thread.Sleep(1000);
7481
Driver.Instance.FindElement(By.CssSelector(".editor-confirmation-sidebar__action > button:nth-child(1)")).Click();
7582

7683

7784

85+
7886
}
7987

8088

PostPage.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
using OpenQA.Selenium;
2+
using System.Threading;
23

34
namespace UnitTestProject1
45
{
56
public class PostPage
67
{
7-
public static string Title
8-
{
9-
get
10-
{
11-
var title = Driver.Instance.FindElement(By.LinkText("This is a Test post title"));
12-
if (title != null)
13-
return title.Text;
14-
return "";
8+
//public static string Title
9+
// {
10+
//get
11+
// {
12+
// Thread.Sleep(800);
13+
//var title = Driver.Instance.FindElement(By.CssSelector(".entry-title"));
14+
//if (title != null)
15+
// return title.Text;
16+
// return "";
1517

1618
}
1719
}
18-
}
19-
}
20+

UnitTest1.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ public void init()
1616
public void TestMethod1()
1717
{
1818
LoginPage.GoTo();
19-
LoginPage.LoginAs("scopethesound").WithPassword("******").Login();
19+
LoginPage.LoginAs("scopethesound").WithPassword("niplifeow").Login();
2020
Assert.IsTrue(DashboardPage.IsAt, "Failed to login");
2121

22+
}
23+
[TestMethod]
24+
public void CheckTags()
25+
{
26+
LoginPage.GoTo();
27+
LoginPage.LoginAs("scopethesound").WithPassword("niplifeow").Login();
28+
CheckLinks.CheckBasicLinks();
29+
2230
}
2331
[TestCleanup]
2432
public void Cleanup()

bin/Debug/UnitTestProject1.dll

0 Bytes
Binary file not shown.

bin/Debug/UnitTestProject1.pdb

2 KB
Binary file not shown.

obj/Debug/UnitTestProject1.dll

0 Bytes
Binary file not shown.

obj/Debug/UnitTestProject1.pdb

2 KB
Binary file not shown.

0 commit comments

Comments
 (0)