-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlogTest.scala
79 lines (69 loc) · 2.57 KB
/
BlogTest.scala
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
72
73
74
75
76
77
78
79
package ui
import io.github.bonigarcia.wdm.WebDriverManager
import io.qameta.allure.scalatest.AllureScalatestContext
import org.openqa.selenium.chrome.{ChromeDriver, ChromeOptions}
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll}
import org.scalatest.concurrent.Eventually
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.time.{Millis, Seconds, Span}
import org.scalatestplus.selenium.WebBrowser
import tags.Smoke
import ui.page.{AboutPage, ContactPage, HomePage}
import scala.language.postfixOps
class BlogTest extends AnyFlatSpec with BeforeAndAfterAll with Matchers with Eventually with WebBrowser {
implicit val webDriver: ChromeDriver = {
WebDriverManager.chromedriver().setup()
val options = new ChromeOptions
options.addArguments("--no-sandbox")
options.addArguments("--disable-dev-shm-usage")
options.addArguments("--headless")
new ChromeDriver(options)
}
override def afterAll(): Unit = {
webDriver.quit()
}
implicitlyWait(Span(3, Seconds))
"User" should "be able to view latest blog post" taggedAs Smoke in new AllureScalatestContext {
val homePage = new HomePage
go to homePage
val posts = findAll(CssSelectorQuery("div.post-preview")).toList
posts should have size 5
val latestPost = posts.head
latestPost.text should not be empty
}
"User" should "be able to open Contact Page" taggedAs Smoke in new AllureScalatestContext {
val homePage = new HomePage
go to homePage
homePage.url should equal (currentUrl)
click on xpath(homePage.contactPageLink)
eventually {
currentUrl != homePage.url
}
val contactPage = new ContactPage
contactPage.url should equal (currentUrl)
}
"User" should "be able to send message to author" taggedAs Smoke in new AllureScalatestContext {
val contactPage = new ContactPage
go to contactPage
contactPage.url should be (currentUrl)
textField(contactPage.nameField).value = "Reader"
click on id(contactPage.emailField)
enter("[email protected]")
click on id(contactPage.phoneField)
enter( "123456789")
textArea(contactPage.messageField).value = "Hello Author"
click on cssSelector(contactPage.sendButton)
}
"User" should "be able to open About Page" taggedAs Smoke in new AllureScalatestContext {
val homePage = new HomePage
go to homePage
homePage.url should equal (currentUrl)
click on xpath(homePage.aboutPageLink)
eventually {
currentUrl != homePage.url
}
val aboutPage = new AboutPage
aboutPage.url should be (currentUrl)
}
}