-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitTest2.cs
71 lines (58 loc) · 3.11 KB
/
UnitTest2.cs
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
70
71
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using System.Threading;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest2
{
static IWebDriver driverFF = null;
[TestMethod]
public void desafio2()
{
String nome = "Mateus";
String email = "teste@teste.com.br";
String telefone = "51 9999 9999";
driverFF = new FirefoxDriver();
driverFF.Navigate().GoToUrl("http://eliasnogueira.com/arquivos_blog/selenium/desafio/2desafio/");
// alterando o nome
IWebElement nomeDisplay = driverFF.FindElement(By.Id("name_rg_display_section"));
nomeDisplay.Click();
IWebElement elementoPessoa = driverFF.FindElement(By.Id("nome_pessoa"));
elementoPessoa.Clear();
elementoPessoa.SendKeys(nome);
driverFF.FindElement(By.CssSelector("#name_hv_editing_section > input[value='Salvar']")).Click();
//Thread.Sleep(5000);
WebDriverWait wait = new WebDriverWait(driverFF, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementExists(By.Id("name_rg_display_section")));
// alterando o e-mail
IWebElement emailDisplay = driverFF.FindElement(By.Id("email_rg_display_section"));
emailDisplay.Click();
IWebElement elementoEmail = driverFF.FindElement(By.Id("email_value"));
elementoEmail.Clear();
elementoEmail.SendKeys(email);
driverFF.FindElement(By.CssSelector("#email_hv_editing_section > input[value='Salvar']")).Click();
//Thread.Sleep(5000);
wait = new WebDriverWait(driverFF, TimeSpan.FromSeconds(5));
wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("email_rg_display_section"), email));
// alterando o telefone
IWebElement telefoneDisplay = driverFF.FindElement(By.Id("phone_rg_display_section"));
telefoneDisplay.Click();
IWebElement elementoTelefone = driverFF.FindElement(By.Id("phone_value"));
elementoTelefone.Clear();
elementoTelefone.SendKeys(telefone);
//Thread.Sleep(5000);
driverFF.FindElement(By.CssSelector("#phone_hv_editing_section > input[value='Salvar']")).Click();
//Thread.Sleep(5000);
wait = new WebDriverWait(driverFF, TimeSpan.FromSeconds(5));
wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("phone_hv_editing_section"), telefone));
//validacoes
Assert.AreEqual(nome, driverFF.FindElement(By.Id("name_rg_display_section")).Text);
Assert.AreEqual("Email: " + email, driverFF.FindElement(By.Id("email_rg_display_section")).Text);
Assert.AreEqual("Telefone: " + telefone, driverFF.FindElement(By.Id("phone_rg_display_section")).Text);
}
}
}