-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeleniumCsharp.cs
More file actions
69 lines (69 loc) · 2.35 KB
/
SeleniumCsharp.cs
File metadata and controls
69 lines (69 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.BiDi.Script;
using OpenQA.Selenium.Chrome;
namespace Selenium_PJ1_Csharp
{
[TestFixture]
public class SeleniumCsharp4
{
[Test]
[Author("Tran Thanh Than Nguyen", "thanhthanh0535@gmail.com")]
[Description("Facebok login verify")]
[TestCaseSource("DataDrivenTesting")]
public void Test1(String urlName)
{
IWebDriver driver = null;
try
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = urlName;
IWebElement emailTextField= driver.FindElement(By.XPath(".*[@name='reg_email__']"));
emailTextField.SendKeys("thanhthanh0535@gmail.com");
driver.Quit();
}
catch (Exception e)
{
ITakesScreenshot ts = driver as ITakesScreenshot;
Screenshot screenshot = ts.GetScreenshot();
screenshot.SaveAsFile("/Users/thanhthanh0535/Selenium_PJ1_Csharp/screenshots/sc1.png");
Console.WriteLine(e.StackTrace);
throw;
}
finally
{
if(driver != null)
{
driver.Quit();
}
}
}
static IList DataDrivenTesting()
{
ArrayList list = new ArrayList();
list.Add("https://www.facebook.com/r.php?entry_point=login");
// list.Add("https://www.youtube.com");
// list.Add("https://www.gmail.com");
return list;
}
// [Test]
// [Author("Tran Thanh Than Nguyen", "thanhthanh0535@gmail.com")]
// [Description("Facebok login verify")]
// public void Test2()
// {
// IWebDriver driver = new ChromeDriver();
// driver.Manage().Window.Maximize();
// driver.Url = "https://www.facebook.com/r.php?entry_point=login";
// IWebElement emailTextField= driver.FindElement(By.XPath(".*[@name='reg_email__']"));
// emailTextField.SendKeys("thanhthanh0535@gmail.com");
// driver.Close();
// }
}
}