-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToSentenceCaseTest.java
More file actions
61 lines (45 loc) · 1.71 KB
/
Copy pathToSentenceCaseTest.java
File metadata and controls
61 lines (45 loc) · 1.71 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
/*
* 1. Prepare the expected result - "Mom is cleaning the window"
* 2. Go to the website https://capitalizemytitle.com
* 3. Input data - mom is cleaning the Window
* 4. Click the Sentence case button
* 5. Get the modified text
* 6. Verify that modified text matches the expected result
*/
import homework.ToSentenceCase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ToSentenceCaseTest {
private static final String URL = "https://capitalizemytitle.com";
private static final String TEST_SENTENCE = "mom is cleaning the Window";
@Test
public void testCapitalizeMyTitle() throws InterruptedException {
final String expectedResult = new ToSentenceCase().toSentenceCase(TEST_SENTENCE);
WebDriver driver = new ChromeDriver();
driver.get(URL);
/*
xpath
//textarea[@id='main_input']
or
css
textarea#main_input
*/
//3 ways to find an element
driver.findElement(By.name("main_input"));
WebElement textArea = driver.findElement(By.xpath("//textarea[@id='main_input']"));
driver.findElement(By.cssSelector("textarea#main_input"));
textArea.sendKeys(TEST_SENTENCE);
Thread.sleep(3000);
WebElement sentenceCaseButton = driver.findElement(By.id("sentencecase"));
sentenceCaseButton.click();
Thread.sleep(3000);
String actualResult = textArea.getAttribute("value");
Assert.assertEquals(expectedResult, actualResult);
driver.quit();
//driver.close();
}
}