-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenChecks.robot
51 lines (40 loc) · 2.15 KB
/
screenChecks.robot
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
*** Settings ***
Library SeleniumLibrary
Library Collections
Library String
*** Keywords ***
Verify Search Bar Is Visible
Wait Until Page Contains Element id:search_product
Verify Searched Term Is Visible
[Arguments] ${searchString}
${titleCaseString} Convert To Title Case ${searchString}
Page Should Contain Element xpath://div[contains(@class, 'productinfo')]//p[contains(text(), '${titleCaseString}')]
Verify Product Is Visible
[Arguments] ${productId}
Page Should Contain Element xpath://a[@data-product-id='${productId}']
Wait For Success Modal
Wait Until Page Contains Element xpath://div[@id='cartModal' and @class='modal show']//h4[contains(text(), 'Added!') and contains(@class, 'modal-title')]
Wait Until Page Contains Element xpath://div[@id='cartModal' and @class='modal show']//p[contains(text(), 'Your product has been added to cart.')]
Wait Until Page Contains Element xpath://div[@id='cartModal' and @class='modal show']//div[@class='modal-body']//a[@href='/view_cart']
Wait Until Page Contains Element xpath://div[@id='cartModal' and @class='modal show']//button[contains(text(), 'Continue Shopping')]
Verify Products In Cart
[Arguments] ${cartIds}
${cartLength} Get Length ${cartIds}
FOR ${i} IN RANGE ${cartLength}
Page Should Contain Element xpath://table[@id='cart_info_table']//tr[@id='product-${cartIds}[${i}]']
END # Assuming product names are displayed in the cart
Verify Cart Total
[Arguments] ${expected_total}
${actualTotal} Extract Cart Total Sum
Should Be Equal As Numbers ${actual_total} ${expected_total}
Extract Cart Total Sum
${elements} Get Web Elements xpath://*[@class='cart_total_price']
@{texts} Create List
FOR ${element} IN @{elements}
${text} Get Text ${element}
${numeric_part} Get Substring ${text} 4
${integer_value} Convert To Integer ${numeric_part}
Append To List ${texts} ${integer_value}
END
${sum_of_elements} Evaluate sum(@{texts})
[Return] ${sum_of_elements}