-
Notifications
You must be signed in to change notification settings - Fork 56
/
TestCases.robot
114 lines (78 loc) · 4.04 KB
/
TestCases.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
*** Settings ***
Documentation Auto1/QA Task
Library SeleniumLibrary
Library String
Library helpers.HelpLib
Library Collections
Suite Setup Open URL Locally
Suite Teardown Close Browser
*** Test Cases ***
TC1 - Check Filters on Advanced Searh Page
Given Open URL AutoHero
And User is on Advanced Search Page
When User Select Filter for First registration
And User Select Filter for Price Decsending
Then Verify all cars are filtered by First Registration
And Verify all Cars are Filtered By Price Descending
*** Keywords ***
Open Tests in Souce Labs
${desired_capabilities}= Create Dictionary
Set to Dictionary ${desired_capabilities} build test_run
Set to Dictionary ${desired_capabilities} platformName Windows 10
Set to Dictionary ${desired_capabilities} name Auto1
Set to Dictionary ${desired_capabilities} browserName chrome
${executor}= Evaluate str('http://milan.novovic:[email protected]:80/wd/hub')
Create Webdriver Remote desired_capabilities=${desired_capabilities} command_executor=${executor}
Open URL Locally
#Open Webdriver hosted on Azure Devops
Create Webdriver Chrome executable_path=D:/a/1/s/node_modules/chromedriver/lib/chromedriver/chromedriver.exe
# Open Browser on Local Machine
# Open Browser https://www.autohero.com/de/search/ chrome
Maximize Browser Window
Open URL AutoHero
Go To https://www.autohero.com/
User is on Advanced Search Page
Sleep 5s
Click Element //button[contains(text(),'Erweiterte Suche')]
Wait Until Element Is Visible //span[contains(text(),'Erstzulassung ab')]
User Select Filter for First registration
Click Element //span[contains(text(),'Erstzulassung ab')]
Wait Until Element Is Visible //select[@name='yearRange.min']/*[text()='2014']
Click Element //select[@name='yearRange.min']/*[text()='2014']
Sleep 3s
Click Element //a[contains(text(),'Ergebnisse')]
Verify all cars are filtered by first registration
#This Keyword will take all elements with registration,
#pass it to python method which will return if there are registration before 2014
Sleep 3s
@{locators} Get Webelements //*[contains(@class,'specItem___')][1]
@{result}= Create List
:FOR ${locator} IN @{locators}
\ ${name}= Get Text ${locator}
\ ${matches}= Get Regexp Matches ${name} \\d{4}
\ Append To List ${result} ${matches}
${flat} Evaluate [item for sublist in ${result} for item in (sublist if isinstance(sublist, list) else [sublist])]
${numbs}= Convert To Integer 2014
:FOR ${locator} IN @{flat}
\ Log ${locator}
\ Run Keyword Unless ${locator} >= ${numbs} Pass
User Select Filter for Price Decsending
Wait Until Element Is Visible //select[contains(@name,'sort')]
Click Element //select[contains(@name,'sort')]
Sleep 2s
Click Element //*[text()='Höchster Preis']
Verify all Cars are Filtered By Price Descending
#Take all prices, create a list, and return as float so to check if list is sorted
Sleep 2s
@{locators} Get Webelements //*[contains(@class,'totalPrice')][1]
${priceAll}= Create List
${sortedList}= Create List
:FOR ${locator} IN @{locators}
\ ${name}= Get Text ${locator}
\ ${matches}= Get Regexp Matches ${name} \^.....
\ Append To List ${priceAll} ${matches}
${flat} Evaluate [item for sublist in ${priceAll} for item in (sublist if isinstance(sublist, list) else [sublist])]
${sortPrices}= Sorted List ${flat}
Should Be Equal as Strings ${sortPrices} True
Log ${sortPrices}
Log ${flat}