summaryrefslogtreecommitdiffstats
path: root/toaster_automation_test.py
blob: 54fc6daa3751a6afa35f50aa4bfc4b3a4f45eb65 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
#!/usr/bin/python
# Copyright

# DESCRIPTION
# This is toaster automation base class and test cases file

# History:
# 2015.03.09  inital version
# 2015.03.23  adding toaster_test.cfg, run_toastertest.py so we can run case by case from outside

# Briefs:
# This file is comprised of 3 parts:
# I:   common utils like sorting, getting attribute.. etc
# II:  base class part, which complies with unittest frame work and
#      contains class selenium-based functions
# III: test cases
#      to add new case: just implement new test_xxx() function in class toaster_cases

# NOTES for cases:
# case 946:
# step 6 - 8 needs to be observed using screenshots
# case 956:
# step 2 - 3 needs to be run manually

import unittest, time, re, sys, getopt, os, logging, string, errno, exceptions
import shutil, argparse, ConfigParser, platform, json

from PIL._imaging import msp_decoder
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import sqlite3 as sqlite
from collections import Counter
import subprocess


###########################################
#                                         #
# PART I: utils stuff                     #
#                                         #
###########################################

class Listattr(object):
    """
    Set of list attribute. This is used to determine what the list content is.
    Later on we may add more attributes here.
    """
    NULL = "null"
    NUMBERS = "numbers"
    STRINGS = "strings"
    PERCENT = "percentage"
    SIZE = "size"
    UNKNOWN = "unknown"


def get_log_root_dir():
    max_depth = 5
    parent_dir = '../'
    for number in range(0, max_depth):
        if os.path.isdir(sys.path[0] + os.sep + (os.pardir + os.sep)*number + 'log'):
            log_root_dir = os.path.abspath(sys.path[0] + os.sep + (os.pardir + os.sep)*number + 'log')
            break

    if number == (max_depth - 1):
        print 'No log dir found. Please check'
        raise Exception

    return log_root_dir


def mkdir_p(dir):
    try:
        os.makedirs(dir)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(dir):
            pass
        else:
            raise


def get_list_attr(testlist):
    """
    To determine the list content
    """
    if not testlist:
        return Listattr.NULL
    listtest = testlist[:]
    try:
        listtest.remove('')
    except ValueError:
        pass
    pattern_percent = re.compile(r"^([0-9])+(\.)?([0-9])*%$")
    pattern_size = re.compile(r"^([0-9])+(\.)?([0-9])*( )*(K)*(M)*(G)*B$")
    pattern_number = re.compile(r"^([0-9])+(\.)?([0-9])*$")
    def get_patterned_number(pattern, tlist):
        count = 0
        for item in tlist:
            if re.search(pattern, item):
                count += 1
        return count
    if get_patterned_number(pattern_percent, listtest) == len(listtest):
        return Listattr.PERCENT
    elif get_patterned_number(pattern_size, listtest) == len(listtest):
        return Listattr.SIZE
    elif get_patterned_number(pattern_number, listtest) == len(listtest):
        return Listattr.NUMBERS
    else:
        return Listattr.STRINGS


def is_list_sequenced(testlist):
    """
    Function to tell if list is sequenced
    Currently we may have list made up of: Strings ; numbers ; percentage ; time; size
    Each has respective way to determine if it's sequenced.
    """
    test_list = testlist[:]
    try:
        test_list.remove('')
    except ValueError:
        pass

    if get_list_attr(testlist) == Listattr.NULL :
        return True

    elif get_list_attr(testlist) == Listattr.STRINGS :
        return (sorted(test_list) == test_list)

    elif get_list_attr(testlist) == Listattr.NUMBERS :
        list_number = []
        for item in test_list:
            list_number.append(eval(item))
        return (sorted(list_number) == list_number)

    elif get_list_attr(testlist) == Listattr.PERCENT :
        list_number = []
        for item in test_list:
            list_number.append(eval(item.strip('%')))
        return (sorted(list_number) == list_number)

    elif get_list_attr(testlist) == Listattr.SIZE :
        list_number = []
        # currently SIZE is splitted by space
        for item in test_list:
            if item.split()[1].upper() == "KB":
                list_number.append(1024 * eval(item.split()[0]))
            elif item.split()[1].upper() == "MB":
                list_number.append(1024 * 1024 * eval(item.split()[0]))
            elif item.split()[1].upper() == "GB":
                list_number.append(1024 * 1024 * 1024 * eval(item.split()[0]))
            else:
                list_number.append(eval(item.split()[0]))
        return (sorted(list_number) == list_number)

    else:
        print 'Unrecognized list type, please check'
        return False


def is_list_inverted(testlist):
    """
    Function to tell if list is inverted
    Currently we may have list made up of: Strings ; numbers ; percentage ; time; size
    Each has respective way to determine if it's inverted.
    """
    test_list = testlist[:]
    try:
        test_list.remove('')
    except ValueError:
        pass

    if get_list_attr(testlist) == Listattr.NULL :
        return True

    elif get_list_attr(testlist) == Listattr.STRINGS :
        return (sorted(test_list, reverse = True) == test_list)

    elif get_list_attr(testlist) == Listattr.NUMBERS :
        list_number = []
        for item in test_list:
            list_number.append(eval(item))
        return (sorted(list_number, reverse = True) == list_number)

    elif get_list_attr(testlist) == Listattr.PERCENT :
        list_number = []
        for item in test_list:
            list_number.append(eval(item.strip('%')))
        return (sorted(list_number, reverse = True) == list_number)

    elif get_list_attr(testlist) == Listattr.SIZE :
        list_number = []
        # currently SIZE is splitted by space. such as 0 B; 1 KB; 2 MB
        for item in test_list:
            if item.split()[1].upper() == "KB":
                list_number.append(1024 * eval(item.split()[0]))
            elif item.split()[1].upper() == "MB":
                list_number.append(1024 * 1024 * eval(item.split()[0]))
            elif item.split()[1].upper() == "GB":
                list_number.append(1024 * 1024 * 1024 * eval(item.split()[0]))
            else:
                list_number.append(eval(item.split()[0]))
        return (sorted(list_number, reverse = True) == list_number)

    else:
        print 'Unrecognized list type, please check'
        return False

def replace_file_content(filename, item, option):
    f = open(filename)
    lines = f.readlines()
    f.close()
    output = open(filename, 'w')
    for line in lines:
        if line.startswith(item):
            output.write(item + " = '" + option + "'\n")
        else:
            output.write(line)
    output.close()

def extract_number_from_string(s):
    """
    extract the numbers in a string. return type is 'list'
    """
    return re.findall(r'([0-9]+)', s)

# Below is decorator derived from toaster backend test code
class NoParsingFilter(logging.Filter):
    def filter(self, record):
        return record.levelno == 100

def LogResults(original_class):
    orig_method = original_class.run

    from time import strftime, gmtime
    caller = 'toaster'
    timestamp = strftime('%Y%m%d%H%M%S',gmtime())
    logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log')
    linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log')

    #rewrite the run method of unittest.TestCase to add testcase logging
    def run(self, result, *args, **kws):
        orig_method(self, result, *args, **kws)
        passed = True
        testMethod = getattr(self, self._testMethodName)
        #if test case is decorated then use it's number, else use it's name
        try:
            test_case = testMethod.test_case
        except AttributeError:
            test_case = self._testMethodName

        class_name = str(testMethod.im_class).split("'")[1]

        #create custom logging level for filtering.
        custom_log_level = 100
        logging.addLevelName(custom_log_level, 'RESULTS')

        def results(self, message, *args, **kws):
            if self.isEnabledFor(custom_log_level):
                self.log(custom_log_level, message, *args, **kws)
        logging.Logger.results = results

        logging.basicConfig(filename=logfile,
                            filemode='w',
                            format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                            datefmt='%H:%M:%S',
                            level=custom_log_level)
        for handler in logging.root.handlers:
            handler.addFilter(NoParsingFilter())
        local_log = logging.getLogger(caller)

        #check status of tests and record it

        for (name, msg) in result.errors:
            if (self._testMethodName == str(name).split(' ')[0]) and (class_name in str(name).split(' ')[1]):
                local_log.results("Testcase "+str(test_case)+": ERROR")
                local_log.results("Testcase "+str(test_case)+":\n"+msg)
                passed = False
        for (name, msg) in result.failures:
            if (self._testMethodName == str(name).split(' ')[0]) and (class_name in str(name).split(' ')[1]):
                local_log.results("Testcase "+str(test_case)+": FAILED")
                local_log.results("Testcase "+str(test_case)+":\n"+msg)
                passed = False
        for (name, msg) in result.skipped:
            if (self._testMethodName == str(name).split(' ')[0]) and (class_name in str(name).split(' ')[1]):
                local_log.results("Testcase "+str(test_case)+": SKIPPED")
                passed = False
        if passed:
            local_log.results("Testcase "+str(test_case)+": PASSED")

        # Create symlink to the current log
        if os.path.exists(linkfile):
            os.remove(linkfile)
        os.symlink(logfile, linkfile)

    original_class.run = run

    return original_class


###########################################
#                                         #
# PART II: base class                     #
#                                         #
###########################################

@LogResults
class toaster_cases_base(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.log = cls.logger_create()

    def setUp(self):
        self.screenshot_sequence = 1
        self.verificationErrors = []
        self.accept_next_alert = True
        self.host_os = platform.system().lower()
        if os.getenv('TOASTER_SUITE'):
            self.target_suite = os.getenv('TOASTER_SUITE')
        else:
            self.target_suite = self.host_os

        self.parser = ConfigParser.SafeConfigParser()
        self.parser.read('toaster_test.cfg')
        self.base_url = eval(self.parser.get('toaster_test_' + self.target_suite, 'toaster_url'))

        # create log dir . Currently , we put log files in log/tmp. After all
        # test cases are done, move them to log/$datetime dir
        self.log_tmp_dir = os.path.abspath(sys.path[0]) + os.sep + 'log' + os.sep + 'tmp'
        try:
            mkdir_p(self.log_tmp_dir)
        except OSError :
            logging.error("%(asctime)s Cannot create tmp dir under log, please check your privilege")
        # self.log = self.logger_create()
        # driver setup
        self.setup_browser()

    @staticmethod
    def logger_create():
        log_file = "toaster-auto-" + time.strftime("%Y%m%d%H%M%S") + ".log"
        if os.path.exists("toaster-auto.log"): os.remove("toaster-auto.log")
        os.symlink(log_file, "toaster-auto.log")

        log = logging.getLogger("toaster")
        log.setLevel(logging.DEBUG)

        fh = logging.FileHandler(filename=log_file, mode='w')
        fh.setLevel(logging.DEBUG)

        ch = logging.StreamHandler(sys.stdout)
        ch.setLevel(logging.INFO)

        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        log.addHandler(fh)
        log.addHandler(ch)

        return log


    def setup_browser(self, *browser_path):
        self.browser = eval(self.parser.get('toaster_test_' + self.target_suite, 'test_browser'))
        print self.browser
        if self.browser == "firefox":
            driver = webdriver.Firefox()
        elif self.browser == "chrome":
            driver = webdriver.Chrome()
        elif self.browser == "ie":
            driver = webdriver.Ie()
        else:
            driver = None
            print "unrecognized browser type, please check"
        self.driver = driver
        self.driver.implicitly_wait(30)
        return self.driver


    def save_screenshot(self,  **log_args):
        """
        This function is used to save screen either by os interface or selenium interface.
        How to use:
        self.save_screenshot(screenshot_type = 'native'/'selenium', log_sub_dir = 'xxx',
                             append_name = 'stepx')
        where native means screenshot func provided by OS,
        selenium means screenshot func provided by selenium webdriver
        """
        types = [log_args.get('screenshot_type')]
        # when no screenshot_type is specified
        if types == [None]:
            types = ['native', 'selenium']
        # normally append_name is used to specify which step..
        add_name = log_args.get('append_name')
        if not add_name:
            add_name = '-'
        # normally there's no need to specify sub_dir
        sub_dir = log_args.get('log_sub_dir')
        if not sub_dir:
            # use casexxx as sub_dir name
            sub_dir = 'case' + str(self.case_no)
        for item in types:
            log_dir = self.log_tmp_dir + os.sep + sub_dir
            mkdir_p(log_dir)
            log_path = log_dir + os.sep +  self.browser + '-' +\
                    item + '-' + add_name + '-' + str(self.screenshot_sequence) + '.png'
            if item == 'native':
                if self.host_os == "linux":
                    os.system("scrot " + log_path)
                elif self.host_os=="darwin":
                    os.system("screencapture -x " + log_path)
            elif item == 'selenium':
                self.driver.get_screenshot_as_file(log_path)
            self.screenshot_sequence += 1

    def browser_delay(self):
        """
        currently this is a workaround for some chrome test.
        Sometimes we need a delay to accomplish some operation.
        But for firefox, mostly we don't need this.
        To be discussed
        """
        if self.browser == "chrome":
            time.sleep(1)
        return


# these functions are not contained in WebDriver class..
    def find_element_by_text(self, string):
        return self.driver.find_element_by_xpath("//*[text()='" + string + "']")


    def find_elements_by_text(self, string):
        return self.driver.find_elements_by_xpath("//*[text()='" + string + "']")


    def find_element_by_text_in_table(self, table_id, text_string):
        """
        This is used to search some certain 'text' in certain table
        """
        try:
            table_element = self.get_table_element(table_id)
            element = table_element.find_element_by_xpath("//*[text()='" + text_string + "']")
        except NoSuchElementException, e:
            print 'no element found'
            raise
        return element


    def find_element_by_link_text_in_table(self, table_id, link_text):
        """
        Assume there're multiple suitable "find_element_by_link_text".
        In this circumstance we need to specify "table".
        """
        try:
            table_element = self.get_table_element(table_id)
            element = table_element.find_element_by_link_text(link_text)
        except NoSuchElementException, e:
            print 'no element found'
            raise
        return element


    def find_elements_by_link_text_in_table(self, table_id, link_text):
        """
        Search link-text in certain table. This helps to narrow down search area.
        """
        try:
            table_element = self.get_table_element(table_id)
            element_list = table_element.find_elements_by_link_text(link_text)
        except NoSuchElementException, e:
            print 'no element found'
            raise
        return element_list


    def find_element_by_partial_link_text_in_table(self, table_id, link_text):
        """
        Search element by partial link text in certain table.
        """
        try:
            table_element = self.get_table_element(table_id)
            element = table_element.find_element_by_partial_link_text(link_text)
            return element
        except NoSuchElementException, e:
            print 'no element found'
            raise


    def find_elements_by_partial_link_text_in_table(self, table_id, link_text):
        """
        Assume there're multiple suitable "find_partial_element_by_link_text".
        """
        try:
            table_element = self.get_table_element(table_id)
            element_list = table_element.find_elements_by_partial_link_text(link_text)
            return element_list
        except NoSuchElementException, e:
            print 'no element found'
            raise


    def find_element_by_xpath_in_table(self, table_id, xpath):
        """
        This helps to narrow down search area. Especially useful when dealing with pop-up form.
        """
        try:
            table_element = self.get_table_element(table_id)
            element = table_element.find_element_by_xpath(xpath)
        except NoSuchElementException, e:
            print 'no element found'
            raise
        return element


    def find_elements_by_xpath_in_table(self, table_id, xpath):
        """
        This helps to narrow down search area. Especially useful when dealing with pop-up form.
        """
        try:
            table_element = self.get_table_element(table_id)
            element_list = table_element.find_elements_by_xpath(xpath)
        except NoSuchElementException, e:
            print 'no elements found'
            raise
        return element_list


    def shortest_xpath(self, pname, pvalue):
        return "//*[@" + pname + "='" + pvalue + "']"


#usually elements in the same column are with same class name. for instance: class="outcome" .TBD
    def get_table_column_text(self, attr_name, attr_value):
        c_xpath = self.shortest_xpath(attr_name, attr_value)
        elements = self.driver.find_elements_by_xpath(c_xpath)
        c_list = []
        for element in elements:
            c_list.append(element.text)
        return c_list


    def get_table_column_text_by_column_number(self, table_id, column_number):
        c_xpath = "//*[@id='" + table_id + "']//td[" + str(column_number) + "]"
        elements = self.driver.find_elements_by_xpath(c_xpath)
        c_list = []
        for element in elements:
            c_list.append(element.text)
        return c_list

    def get_text_from_elements(self, css_selector):
        elements = self.driver.find_elements_by_css_selector(css_selector)
        return map(lambda x: x.text, elements)


    def get_table_head_text(self, *table_id):
#now table_id is a tuple...
        if table_id:
            thead_xpath = "//*[@id='" + table_id[0] + "']//thead//th[text()]"
            elements = self.driver.find_elements_by_xpath(thead_xpath)
            c_list = []
            for element in elements:
                if element.text:
                    c_list.append(element.text)
            return c_list
#default table on page
        else:
            return self.driver.find_element_by_xpath("//*/table/thead").text



    def get_table_element(self, table_id, *coordinate):
        if len(coordinate) == 0:
#return whole-table element
            element_xpath = "//*[@id='" + table_id + "']"
            try:
                element = self.driver.find_element_by_xpath(element_xpath)
            except NoSuchElementException, e:
                raise
            return element
        row = coordinate[0]

        if len(coordinate) == 1:
#return whole-row element
            element_xpath = "//*[@id='" + table_id + "']/tbody/tr[" + str(row) + "]"
            try:
                element = self.driver.find_element_by_xpath(element_xpath)
            except NoSuchElementException, e:
                return False
            return element
#now we are looking for an element with specified X and Y
        column = coordinate[1]

        element_xpath = "//*[@id='" + table_id + "']/tbody/tr[" + str(row) + "]/td[" + str(column) + "]"
        try:
            element = self.driver.find_element_by_xpath(element_xpath)
        except NoSuchElementException, e:
            return False
        return element


    def get_table_data(self, table_id, row_count, column_count):
        row = 1
        Lists = []
        while row <= row_count:
            column = 1
            row_content=[]
            while column <= column_count:
                s= "//*[@id='" + table_id + "']/tbody/tr[" + str(row) +"]/td[" + str(column) + "]"
                v = self.driver.find_element_by_xpath(s).text
                row_content.append(v)
                column = column + 1
                #print("row_content=",row_content)
            Lists.extend(row_content)
            #print Lists[row-1][0]
            row = row + 1
        return Lists

    def get_table_data_from_class(self, table_class, row_count, column_count):
        row = 1
        Lists = []
        while row <= row_count:
            column = 1
            row_content=[]
            while column <= column_count:
                s= "//table[@class='" + table_class + "']/tbody/tr[" + str(row) +"]/td[" + str(column) + "]"
                v = self.driver.find_element_by_xpath(s).text
                row_content.append(v)
                column = column + 1
                #print("row_content=",row_content)
            Lists.extend(row_content)
            #print Lists[row-1][0]
            row = row + 1
        return Lists

    # The is_xxx_present functions only returns True/False
    # All the log work is done in test procedure, so we can easily trace back
    # using logging
    def is_text_present (self, patterns):
        for pattern in patterns:
            if str(pattern) not in self.driver.page_source:
                print 'Text "'+pattern+'" is missing'
                return False
        return True


    def is_element_present(self, how, what):
        try:
            self.driver.find_element(how, what)
        except NoSuchElementException, e:
            print 'Could not find element '+str(what)+' by ' + str(how)
            return False
        return True


    def is_alert_present(self):
        try: self.driver.switch_to_alert()
        except NoAlertPresentException, e: return False
        return True


    def close_alert_and_get_its_text(self):
        try:
            alert = self.driver.switch_to_alert()
            alert_text = alert.text
            if self.accept_next_alert:
                alert.accept()
            else:
                alert.dismiss()
            return alert_text
        finally: self.accept_next_alert = True


    def get_case_number(self):
        """
        what case are we running now
        """
        funcname = sys._getframe(1).f_code.co_name
        caseno_str = funcname.strip('test_')
        try:
            caseno = int(caseno_str)
        except ValueError:
            print "get case number error! please check if func name is test_xxx"
            return False
        return caseno


    def tearDown(self):
        self.log.info(' END: CASE %s log \n\n' % str(self.case_no))
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

    def get_list_elements(self, ul_id):
        elements = []
        html_list = self.driver.find_element_by_id(ul_id)
        items = html_list.find_elements_by_tag_name("li")
        for item in items:
            text = item.text
            elements.append(text)

        return elements

    def get_editcolumns_list_elements_by_class(self, ul_class):
        elements = []
        html_list = self.driver.find_element_by_css_selector(ul_class)
        items = html_list.find_elements_by_tag_name("li")
        for item in items:
            elements.append(item)

        return elements

    def wait_until_build_finish(self, count_increment, timeout):
        self.driver.refresh()
        #check progress bar is displayed to signal a build has started
        try:
            self.driver.find_element_by_xpath("//div[@class='progress']").is_displayed()
        except:
            print "Unable to start new build"
            self.fail(msg="Unable to start new build")
        count = 0
        failflag = False
        try:
            self.driver.refresh()
            time.sleep(1)
            print "First check starting"
            while (self.driver.find_element_by_xpath("//div[@class='progress']").is_displayed()):
                #print "Looking for build in progress"
                print 'Builds running for '+str(count)+' minutes'
                count += count_increment
                #timeout default is at 179 minutes(3 hours); see set_up method to change
                if (count > timeout):
                    failflag = True
                    print 'Builds took longer than expected to complete; Failing due to possible build stuck.'
                    self.fail()
                time.sleep(count_increment*60)
                self.driver.refresh()
        except:
           try:
                if failflag:
                    self.fail(msg="Builds took longer than expected to complete; Failing due to possible build stuck.")
                print "Looking for successful build"
                try:
                    self.driver.find_element_by_xpath("//div[@class='alert build-result alert-success']").is_displayed()
                except:
                    self.driver.find_element_by_xpath("//div[@class='alert build-result alert-success project-name']").is_displayed()
           except:
                if failflag:
                    self.fail(msg="Builds took longer than expected to complete; Failing due to possible build stuck.")
                print 'Builds did not complete successfully'
                self.fail(msg="Builds did not complete successfully.")
        print "Builds complete!"

###################################################################
#                                                                 #
# PART III: test cases                                            #
# please refer to                                                 #
# https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=xxx  #
#                                                                 #
###################################################################

# Note: to comply with the unittest framework, we call these test_xxx functions
# from run_toastercases.py to avoid calling setUp() and tearDown() multiple times


class toaster_cases(toaster_cases_base):
        ##############
        #  CASE 901  #
        ##############
    def test_901(self):
        # the reason why get_case_number is not in setUp function is that
        # otherwise it returns "setUp" instead of "test_xxx"
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # open all columns
        time.sleep(5)
        self.driver.find_element_by_id("edit-columns-button").click()
        # adding explicitly wait for chromedriver..-_-
        self.browser_delay()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.browser_delay()
        self.driver.find_element_by_id("checkbox-time").click()
        self.browser_delay()
        self.driver.find_element_by_id("checkbox-project").click()
        self.browser_delay()
        self.driver.find_element_by_id("edit-columns-button").click()
        # dict: {lint text name : actual class name}
        table_head_dict = {'Outcome':'outcome', 'Machine':'machine', 'Started on':'started_on', 'Completed on':'completed_on', \
                'Warnings':'warnings_no','Errors':'errors_no'}
        for key in table_head_dict:
            try:
                self.driver.find_element_by_link_text(key).click()
                time.sleep(2)
            except Exception, e:
                self.log.error("%s cannot be found on page" % key)
                raise
            selector = "td[class='%s']" % table_head_dict[key]
            column_list = self.get_text_from_elements(selector)
            # after 1st click, the list should be either sequenced or inverted, but we don't have a "default order" here
            # the point is, after another click, it should be another order
            if is_list_inverted(column_list):
                self.driver.find_element_by_link_text(key).click()
                time.sleep(2)
                column_list = self.get_text_from_elements(selector)
                self.assertTrue(is_list_sequenced(column_list), msg=("%s column not in order" % key))
            else:
                self.assertTrue(is_list_sequenced(column_list), msg=("%s column not sequenced" % key))
                self.driver.find_element_by_link_text(key).click()
                time.sleep(2)
                column_list = self.get_text_from_elements(selector)
                self.assertTrue(is_list_inverted(column_list), msg=("%s column not inverted" % key))
        self.log.info("case passed")


        ##############
        #  CASE 902  #
        ##############
    def test_902(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # Could add more test patterns here in the future. Also, could search some items other than target column in future..
        patterns = ["minimal", "sato"]

        for pattern in patterns:
            ori_target_column_texts = self.get_table_column_text("class", "target")
            self.driver.find_element_by_id("search-input-allbuildstable").clear()
            self.driver.find_element_by_id("search-input-allbuildstable").send_keys(pattern)
            self.driver.find_element_by_id("search-submit-allbuildstable").click()
            time.sleep(3)
            new_target_column_texts = self.get_table_column_text("class", "target")
            print new_target_column_texts
            # if nothing found, we still count it as "pass"
            if new_target_column_texts:
                for text in new_target_column_texts:
                    self.assertTrue(text.find(pattern), msg=("%s item doesn't exist " % pattern))
            time.sleep(2)
            self.driver.find_element_by_id("search-input-allbuildstable").clear()
            self.driver.find_element_by_id("search-submit-allbuildstable").click()
            target_column_texts = self.get_table_column_text("class", "target")
            self.assertTrue(ori_target_column_texts == target_column_texts, msg=("builds changed after operations"))


        ##############
        #  CASE 903  #
        ##############
    def test_903(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # when opening a new page, "started_on" is not displayed by default
        self.driver.find_element_by_id("edit-columns-button").click()
        # currently all the delay are for chrome driver -_-
        self.browser_delay()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        # step 4
        filter_list = ['outcome_filter', 'started_on_filter', 'completed_on_filter','failed_tasks_filter']
        for key in filter_list:
            try:
                self.assertTrue(self.driver.find_element_by_id(key))
            except Exception,e:
                self.assertFalse(True, msg=(" %s cannot be found! %s" % (key, e)))
                raise

        # step 5-6
        for key in filter_list:
            time.sleep(2)
            self.driver.find_element_by_id(key).click()
            time.sleep(2)
            self.browser_delay()

            #click on radio-button 2 if is clickable
            temp = self.driver.find_elements_by_class_name('radio')
            temp[1].click()
            # click "Apply" button
            self.driver.find_element_by_css_selector('.btn.btn-primary').click()
            self.save_screenshot(screenshot_type='selenium', append_name='step5-%s' %(key))

        self.driver.find_element_by_id("search-input-allbuildstable").clear()
        self.driver.find_element_by_id("search-input-allbuildstable").send_keys("core-image")
        self.driver.find_element_by_id("search-submit-allbuildstable").click()


        ##############
        #  CASE 904  #
        ##############
    def test_904(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_partial_link_text("core-image-minimal").click()
        self.driver.find_element_by_link_text("Tasks").click()
        self.table_name = 'otable'
        # This is how we find the "default" rows-number!
        rows_displayed = int(Select(self.driver.find_element_by_css_selector("select.pagesize")).first_selected_option.text)
        print rows_displayed
        self.assertTrue(self.get_table_element(self.table_name, rows_displayed), msg=("not enough rows displayed"))
        self.assertFalse(self.get_table_element(self.table_name, rows_displayed + 1), \
                         msg=("more rows displayed than expected"))
        # Search text box background text is "Search tasks"
        self.assertTrue(self.driver.find_element_by_xpath("//*[@id='searchform']/*[@placeholder='Search tasks']"),\
                        msg=("background text doesn't exist"))
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("busybox")
        self.driver.find_element_by_id("search-button").click()
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step5')
        self.driver.find_element_by_css_selector("i.icon-remove").click()
        # Save screen here
        self.save_screenshot(screenshot_type='selenium', append_name='step5_2')
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("cpu_used").click()
        self.driver.find_element_by_id("disk_io").click()
        self.driver.find_element_by_id("recipe_version").click()
        self.driver.find_element_by_id("time_taken").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        # The operation is the same as case901
        # dict: {lint text name : actual class name}
        table_head_dict = {'Order':'order', 'Recipe':'recipe_name', 'Task':'task_name', 'Executed':'executed', \
                           'Outcome':'outcome', 'Cache attempt':'cache_attempt', 'Time (secs)':'time_taken', 'CPU usage':'cpu_used', \
                           'Disk I/O (ms)':'disk_io'}
        for key in table_head_dict:
        # This is tricky here: we are doing so because there may be more than 1
        # same-name link_text in one page. So we only find element inside the table
            self.find_element_by_link_text_in_table(self.table_name, key).click()
            selector = "td[class='%s']" % table_head_dict[key]
            column_list = self.get_text_from_elements(selector)
            #column_list = self.get_table_column_text("class", table_head_dict[key])
        # after 1st click, the list should be either sequenced or inverted, but we don't have a "default order" here
        # the point is, after another click, it should be another order
        # the first case is special:this means every item in column_list is the same, so
        # after one click, either sequenced or inverted will be fine
            if (is_list_inverted(column_list) and is_list_sequenced(column_list)) \
                or (not column_list) :
                self.find_element_by_link_text_in_table(self.table_name, key).click()
                column_list = self.get_text_from_elements(selector)
                #column_list = self.get_table_column_text("class", table_head_dict[key])
                self.assertTrue(is_list_sequenced(column_list) or is_list_inverted(column_list), \
                                msg=("%s column not in any order" % key))
            elif is_list_inverted(column_list):
                self.find_element_by_link_text_in_table(self.table_name, key).click()
                column_list = self.get_text_from_elements(selector)
                #column_list = self.get_table_column_text("class", table_head_dict[key])
                self.assertTrue(is_list_sequenced(column_list), msg=("%s column not in order" % key))
            else:
                self.assertTrue(is_list_sequenced(column_list), msg=("%s column not in order" % key))
                self.find_element_by_link_text_in_table(self.table_name, key).click()
                column_list = self.get_text_from_elements(selector)
                #column_list = self.get_table_column_text("class", table_head_dict[key])
                self.assertTrue(is_list_inverted(column_list), msg=("%s column not inverted" % key))
        # step 8-10
        # filter dict: {link text name : filter table name in xpath}
        filter_dict = {'Executed':'filter_executed', 'Outcome':'filter_outcome', 'Cache attempt':'filter_cache_attempt'}
        for key in filter_dict:
            temp_element = self.find_element_by_link_text_in_table(self.table_name, key)
            # find the filter icon besides it.
            # And here we must have break (1 sec) to get the popup stuff
            temp_element.find_element_by_xpath("..//*[@class='icon-filter filtered']").click()
            self.browser_delay()
            avail_options = self.driver.find_elements_by_xpath("//*[@id='" + filter_dict[key] + "']//*[@name='filter'][not(@disabled)]")
            for number in range(0, len(avail_options)):
                avail_options[number].click()
                self.browser_delay()
                # click "Apply"
                self.driver.find_element_by_xpath("//*[@id='" + filter_dict[key]  + "']//*[@type='submit']").click()
                # insert screen capture here
                self.browser_delay()
                self.save_screenshot(screenshot_type='selenium', append_name='step8')
                # after the last option was clicked, we don't need operation below anymore
                if number < len(avail_options)-1:
                     try:
                        temp_element = self.find_element_by_link_text_in_table(self.table_name, key)
                        temp_element.find_element_by_xpath("..//*[@class='icon-filter filtered']").click()
                        avail_options = self.driver.find_elements_by_xpath("//*[@id='" + filter_dict[key] + "']//*[@name='filter'][not(@disabled)]")
                     except:
                        print "in exception"
                        self.find_element_by_text("Show all tasks").click()
#                        self.driver.find_element_by_xpath("//*[@id='searchform']/button[2]").click()
                        temp_element = self.find_element_by_link_text_in_table(self.table_name, key)
                        temp_element.find_element_by_xpath("..//*[@class='icon-filter filtered']").click()
                        avail_options = self.driver.find_elements_by_xpath("//*[@id='" + filter_dict[key] + "']//*[@name='filter'][not(@disabled)]")
                     self.browser_delay()
        # step 11
        for item in ['order', 'task_name', 'executed', 'outcome', 'recipe_name', 'recipe_version']:
            try:
                self.find_element_by_xpath_in_table(self.table_name, "./tbody/tr[1]/*[@class='" + item + "']/a").click()
            except NoSuchElementException, e:
            # let it go...
                print 'no item in the colum' + item
            # insert screen shot here
            self.save_screenshot(screenshot_type='selenium', append_name='step11')
            self.driver.back()
        # step 12-14
        # about test_dict: please refer to testcase 904 requirement step 12-14
        test_dict = {
            'Time':{
                'class':'time_taken',
                'check_head_list':['Recipe', 'Task', 'Executed', 'Outcome', 'Time (secs)'],
                'check_column_list':['cpu_used', 'cache_attempt', 'disk_io', 'order', 'recipe_version']
            },
            'CPU usage':{
                'class':'cpu_used',
                'check_head_list':['Recipe', 'Task', 'Executed', 'Outcome', 'CPU usage'],
                'check_column_list':['cache_attempt', 'disk_io', 'order', 'recipe_version', 'time_taken']
            },
            'Disk I/O':{
                'class':'disk_io',
                'check_head_list':['Recipe', 'Task', 'Executed', 'Outcome', 'Disk I/O (ms)'],
                'check_column_list':['cpu_used', 'cache_attempt', 'order', 'recipe_version', 'time_taken']
            }
        }
        for key in test_dict:
            self.find_element_by_partial_link_text_in_table('nav', 'core-image').click()
            self.find_element_by_link_text_in_table('nav', key).click()
            head_list = self.get_table_head_text('otable')
            for item in test_dict[key]['check_head_list']:
                self.assertTrue(item in head_list, msg=("%s not in head row" % item))
            column_list = self.get_table_column_text('class', test_dict[key]['class'])
            self.assertTrue(is_list_inverted(column_list), msg=("%s column not inverted" % key))

            self.driver.find_element_by_id("edit-columns-button").click()
            for item2 in test_dict[key]['check_column_list']:
                self.driver.find_element_by_id(item2).click()
            self.driver.find_element_by_id("edit-columns-button").click()
            # TBD: save screen here


        ##############
        #  CASE 906  #
        ##############
    def test_906(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'Packages').click()
        print "1"
        # find "bash" in first column (Packages)
        time.sleep(4)
        self.driver.find_element_by_xpath("//*[@id='otable']//td[1]//*[text()='bash']").click()

        print "2"
        # save sceen here to observe...
        # step 6
        self.driver.find_element_by_partial_link_text("Generated files").click()
        head_list = self.get_table_head_text('otable')
        for item in ['File', 'Size']:
            print item
            self.assertTrue(item in head_list, msg=("%s not in head row" % item))
        c_list = self.get_table_column_text('class', 'path')
        self.assertTrue(is_list_sequenced(c_list), msg=("column not in order"))
        # step 7
        self.driver.find_element_by_partial_link_text("Runtime dependencies").click()
        # save sceen here to observe...
        # note that here table name is not 'otable'
        head_list = self.get_table_head_text('dependencies')
        for item in ['Package', 'Version', 'Size']:
            print item
            self.assertTrue(item in head_list, msg=("%s not in head row" % item))
        c_list = self.get_table_column_text_by_column_number('dependencies', 1)
        self.assertTrue(is_list_sequenced(c_list), msg=("list not in order"))
        texts = ['Size', 'License', 'Recipe', 'Recipe version', 'Layer', \
                     'Layer commit']
        self.failUnless(self.is_text_present(texts))


        ##############
        #  CASE 910  #
        ##############
    def test_910(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        image_type="core-image-minimal"
        test_package1="busybox"
        test_package2="lib"
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text(image_type).click()
        self.driver.find_element_by_link_text("Recipes").click()
        self.save_screenshot(screenshot_type='selenium', append_name='step3')

        self.table_name = 'otable'
        # This is how we find the "default" rows-number!
        rows_displayed = int(Select(self.driver.find_element_by_css_selector("select.pagesize")).first_selected_option.text)
        print rows_displayed
        self.assertTrue(self.get_table_element(self.table_name, rows_displayed))
        self.assertFalse(self.get_table_element(self.table_name, rows_displayed + 1))
        # Check the default table is sorted by Recipe
        tasks_column_count = len(self.driver.find_elements_by_xpath("/html/body/div[2]/div/div[2]/div[2]/table/tbody/tr/td[1]"))
        print tasks_column_count
        default_column_list = self.get_table_column_text_by_column_number(self.table_name, 1)
        #print default_column_list

        self.assertTrue(is_list_sequenced(default_column_list))
        # Search text box background text is "Search recipes"
        self.assertTrue(self.driver.find_element_by_xpath("//*[@id='searchform']/*[@placeholder='Search recipes']"))
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys(test_package1)
        self.driver.find_element_by_id("search-button").click()
        # Save screen here
        self.save_screenshot(screenshot_type='selenium', append_name='step4')
        self.driver.find_element_by_css_selector("i.icon-remove").click()
        self.save_screenshot(screenshot_type='selenium', append_name='step4_2')
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("depends_on").click()
        self.driver.find_element_by_id("layer_version__branch").click()
        self.driver.find_element_by_id("layer_version__layer__commit").click()
        self.driver.find_element_by_id("depends_by").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        self.find_element_by_link_text_in_table(self.table_name, 'Recipe').click()
        # Check the inverted table by Recipe
        # Recipe doesn't have class name
        #inverted_tasks_column_count = len(self.driver.find_elements_by_xpath("/html/body/div[2]/div/div[2]/div[2]/table/tbody/tr/td[1]"))
        #print inverted_tasks_column_count
        #inverted_column_list = self.get_table_column_text_by_column_number(self.table_name, 1)
        #print inverted_column_list

        #self.driver.find_element_by_partial_link_text("zlib").click()
        #self.driver.back()
        #self.assertTrue(is_list_inverted(inverted_column_list))
        #self.find_element_by_link_text_in_table(self.table_name, 'Recipe').click()

        table_head_dict = {'Recipe':'recipe__name', 'Section':'recipe_section', \
                'License':'recipe_license', 'Layer':'layer_version__layer__name', \
                'Layer branch':'layer_version__branch'}
        #'Recipe file':'recipe_file',
        for key in table_head_dict:
            self.find_element_by_link_text_in_table(self.table_name, key).click()
            selector = "td[class='%s']" % table_head_dict[key]
            column_list = self.get_text_from_elements(selector)
            #column_list = self.get_table_column_text("class", table_head_dict[key])

            if (is_list_inverted(column_list) and is_list_sequenced(column_list)) \
                    or (not column_list) :
                self.find_element_by_link_text_in_table(self.table_name, key).click()
                #column_list = self.get_table_column_text("class", table_head_dict[key])
                column_list = self.get_text_from_elements(selector)

                self.assertTrue(is_list_sequenced(column_list) or is_list_inverted(column_list))
                self.driver.find_element_by_partial_link_text("acl").click()
                self.driver.back()
                self.assertTrue(is_list_sequenced(column_list) or is_list_inverted(column_list))
                # Search text box background text is "Search recipes"
                self.assertTrue(self.driver.find_element_by_xpath("//*[@id='searchform']/*[@placeholder='Search recipes']"))
                self.driver.find_element_by_id("search").clear()
                self.driver.find_element_by_id("search").send_keys(test_package2)
                self.driver.find_element_by_id("search-button").click()
                #column_search_list = self.get_table_column_text("class", table_head_dict[key])
                column_search_list = self.get_text_from_elements(selector)

                self.assertTrue(is_list_sequenced(column_search_list) or is_list_inverted(column_search_list))
                self.driver.find_element_by_css_selector("i.icon-remove").click()
            elif is_list_inverted(column_list):
                self.find_element_by_link_text_in_table(self.table_name, key).click()
                time.sleep(2)
                #column_list = self.get_table_column_text("class", table_head_dict[key])
                column_list = self.get_text_from_elements(selector)

                self.assertTrue(is_list_sequenced(column_list))
                self.driver.find_element_by_partial_link_text("acl").click()
                self.driver.back()
                self.assertTrue(is_list_sequenced(column_list))
                # Search text box background text is "Search recipes"
                self.assertTrue(self.driver.find_element_by_xpath("//*[@id='searchform']/*[@placeholder='Search recipes']"))
                self.driver.find_element_by_id("search").clear()
                self.driver.find_element_by_id("search").send_keys(test_package2)
                self.driver.find_element_by_id("search-button").click()
                #column_search_list = self.get_table_column_text("class", table_head_dict[key])
                column_search_list = self.get_text_from_elements(selector)
                self.assertTrue(is_list_sequenced(column_search_list))
                self.driver.find_element_by_css_selector("i.icon-remove").click()
            else:
                self.assertTrue(is_list_sequenced(column_list),  msg=("list %s not sequenced" % key))
                self.find_element_by_link_text_in_table(self.table_name, key).click()
                time.sleep(5)
                #column_list = self.get_table_column_text("class", table_head_dict[key])
                column_list = self.get_text_from_elements(selector)

                time.sleep(5)

                self.assertTrue(is_list_inverted(column_list))

                try:
                    self.driver.find_element_by_partial_link_text("acl").click()
                    time.sleep(5)
                except:
                    self.driver.find_element_by_partial_link_text("zlib").click()
                    time.sleep(5)
                self.driver.back()

                self.assertTrue(is_list_inverted(column_list))
                # Search text box background text is "Search recipes"
                self.assertTrue(self.driver.find_element_by_xpath("//*[@id='searchform']/*[@placeholder='Search recipes']"))
                self.driver.find_element_by_id("search").clear()
                self.driver.find_element_by_id("search").send_keys(test_package2)
                self.driver.find_element_by_id("search-button").click()
                #column_search_list = self.get_table_column_text("class", table_head_dict[key])
                time.sleep(10)
                column_search_list = self.get_text_from_elements(selector)
                self.assertTrue(is_list_inverted(column_search_list))
                #self.driver.find_element_by_css_selector("i.icon-remove").click()
                self.driver.find_element_by_id("search").clear()
                self.driver.find_element_by_id("search-button").click()
        """
        # Bug 5919
        print "bug"
        for key in table_head_dict:
            print key
            self.find_element_by_link_text_in_table(self.table_name, key).click()
            self.driver.find_element_by_id("edit-columns-button").click()
            if key == 'Recipe':
                print "pass"
            else:
                self.driver.find_element_by_id(table_head_dict[key]).click()
            self.driver.find_element_by_id("edit-columns-button").click()
            self.browser_delay()
            # After hide the column, the default table should be sorted by Recipe
            tasks_column_count = len(self.driver.find_elements_by_partial_link_text("acl"))
            #print tasks_column_count
            default_column_list = self.get_table_column_text_by_column_number(self.table_name, 1)
            #print default_column_list
            self.assertTrue(is_list_sequenced(default_column_list))

        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("recipe_file").click()
        self.driver.find_element_by_id("recipe_section").click()
        self.driver.find_element_by_id("recipe_license").click()
        self.driver.find_element_by_id("layer_version__layer__name").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        """

        ##############
        #  CASE 911  #
        ##############
    def test_911(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'Recipes').click()
        # step 3-5
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("lib")
        self.driver.find_element_by_id("search-button").click()
        # save screen here for observation
        self.save_screenshot(screenshot_type='selenium', append_name='step5')
        # step 6
        self.driver.find_element_by_css_selector("i.icon-remove").click()
        self.driver.find_element_by_id("search").clear()
        # we deliberately want "no result" here
        self.driver.find_element_by_id("search").send_keys("no such input")
        self.driver.find_element_by_id("search-button").click()
        try:
            self.find_element_by_text("Show all recipes").click()
        except:
            self.fail(msg='Could not identify blank page elements')

        ##############
        #  CASE 912  #
        ##############
    def test_912(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'Recipes').click()
        # step 3
        head_list = self.get_table_head_text('otable')
        for item in ['Recipe', 'Recipe version', 'Recipe file', 'Section', 'License', 'Layer']:
            self.assertTrue(item in head_list, msg=("item %s not in head row" % item))
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("depends_on").click()
        self.driver.find_element_by_id("layer_version__branch").click()
        self.driver.find_element_by_id("layer_version__layer__commit").click()
        self.driver.find_element_by_id("depends_by").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        # check if columns selected above is shown
        check_list = ['Dependencies', 'Layer branch', 'Layer commit', 'Reverse dependencies']
        head_list = self.get_table_head_text('otable')
        time.sleep(2)
        print head_list
        for item in check_list:
            self.assertTrue(item in head_list, msg=("item %s not in head row" % item))
        # un-check 'em all
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("depends_on").click()
        self.driver.find_element_by_id("layer_version__branch").click()
        self.driver.find_element_by_id("layer_version__layer__commit").click()
        self.driver.find_element_by_id("depends_by").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        # don't exist any more
        head_list = self.get_table_head_text('otable')
        for item in check_list:
            self.assertFalse(item in head_list, msg=("item %s should not be in head row" % item))


        ##############
        #  CASE 913  #
        ##############
    def test_913(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'Recipes').click()
        # step 3
        head_list = self.get_table_head_text('otable')
        for item in ['Recipe', 'Recipe version', 'Recipe file', 'Section', 'License', 'Layer']:
            self.assertTrue(item in head_list, msg=("item %s not in head row" % item))
        # step 4
        self.driver.find_element_by_id("edit-columns-button").click()
        # save screen
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step4')
        self.driver.find_element_by_id("edit-columns-button").click()

        ##############
        #  CASE 914  #
        ##############
    def test_914(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        image_type="core-image-minimal"

        dict_key_tasks = {'busybox':["do_fetch", "do_unpack",  "do_patch", "do_configure", "do_compile", "do_install", "do_package", "do_build"] , \
                          'gdbm':["do_fetch", "do_unpack",  "do_patch", "do_configure", "do_compile", "do_install", "do_package", "do_build"] ,\
                          'gettext-native':["do_fetch", "do_unpack",  "do_patch", "do_configure", "do_compile", "do_install", "do_build"]}

        driver = self.driver
        driver.maximize_window()
        driver.get(self.base_url)
        driver.find_element_by_link_text(image_type).click()
        time.sleep(2)
        for test_package in dict_key_tasks:
            driver.find_element_by_link_text("Recipes").click()
            time.sleep(2)
            self.driver.find_element_by_id("search").clear()
            self.driver.find_element_by_id("search").send_keys(test_package)
            self.driver.find_element_by_id("search-button").click()
            time.sleep(2)
            driver.find_element_by_link_text(test_package).click()

            self.table_name = 'information'

            tasks_row_count = len(driver.find_elements_by_xpath("//*[@id='"+self.table_name+"']/table/tbody/tr/td[1]"))
            tasks_column_count = len(driver.find_elements_by_xpath("//*[@id='"+self.table_name+"']/table/tbody/tr[1]/td"))
            print 'rows: '+str(tasks_row_count)
            print 'columns: '+str(tasks_column_count)

            Tasks_column = self.get_table_column_text_by_column_number(self.table_name, 2)
            print ("Tasks_column=", Tasks_column)



            #for key in dict_key_tasks:
            key_tasks= dict_key_tasks[test_package]

            i = 0
            while i < len(key_tasks):
                if key_tasks[i] not in Tasks_column:
                    print ("Error! Missing key task: %s" % key_tasks[i])
                else:
                    print ("%s is in tasks" % key_tasks[i])
                i = i + 1

            if Tasks_column.index(key_tasks[0]) != 0:
                print ("Error! %s is not in the right position" % key_tasks[0])
            else:
                print ("%s is in right position" % key_tasks[0])

            if Tasks_column[-1] != key_tasks[-1]:
                print ("Error! %s is not in the right position" % key_tasks[-1])
            else:
                print ("%s is in right position" % key_tasks[-1])

            driver.find_element_by_partial_link_text("Packages (").click()
            time.sleep(2)



            packages_name = driver.find_element_by_partial_link_text("Packages (").text
            print packages_name
            packages_num = int(filter(str.isdigit, repr(packages_name)))
            print packages_num

            if(packages_num !=0):
                #switch the table to show more than 10 rows at a time
                Select(driver.find_element_by_xpath(".//*[@id='packages-built']/div[1]/div/select")).select_by_value('150')

            packages_row_count = len(driver.find_elements_by_xpath(".//*[@id='otable']/tbody/tr/td[1]"))

            print packages_row_count

            if packages_num != packages_row_count:
                print ("Error! The packages number is not correct")
            else:
                print ("The packages number is correct")

            driver.find_element_by_partial_link_text("Build dependencies (").click()
            depends_name = driver.find_element_by_partial_link_text("Build dependencies (").text
            print depends_name
            depends_num = int(filter(str.isdigit, repr(depends_name)))
            print depends_num

            if depends_num == 0:
                depends_message = repr(driver.find_element_by_css_selector("div.alert.alert-info").text)
                print depends_message
                if depends_message.find("has no build dependencies.") < 0:
                    print ("Error! The message isn't expected.")
                else:
                    print ("The message is expected")
            else:
                depends_row_count = len(driver.find_elements_by_xpath("//*[@id='dependencies']/table/tbody/tr/td[1]"))
                print depends_row_count
                if depends_num != depends_row_count:
                    print ("Error! The dependent packages number is not correct")
                else:
                    print ("The dependent packages number is correct")

            driver.find_element_by_partial_link_text("Reverse build dependencies (").click()
            rdepends_name = driver.find_element_by_partial_link_text("Reverse build dependencies (").text
            print rdepends_name
            rdepends_num = int(filter(str.isdigit, repr(rdepends_name)))
            print rdepends_num

            if rdepends_num == 0:
                rdepends_message = repr(driver.find_element_by_css_selector("#brought-in-by > div.alert.alert-info").text)
                print rdepends_message
                if rdepends_message.find("has no reverse build dependencies.") < 0:
                    print ("Error! The message isn't expected.")
                else:
                    print ("The message is expected")
            else:
                print ("The reverse dependent packages number is correct")


        ##############
        #  CASE 915  #
        ##############
    def test_915(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        # step 3
        self.find_element_by_link_text_in_table('nav', 'Configuration').click()
        self.driver.find_element_by_link_text("BitBake variables").click()
        # step 4
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("lib")
        self.driver.find_element_by_id("search-button").click()
        # save screen to see result
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step4')
        # step 5
        self.driver.find_element_by_css_selector("i.icon-remove").click()
        head_list = self.get_table_head_text('otable')
        print head_list
        print len(head_list)
        self.assertTrue(head_list == ['Variable', 'Value', 'Set in file', 'Description'], \
                        msg=("head row contents wrong"))
        # step 8
        # search other string. and click "Variable" to re-sort, check if table
        # head is still the same
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("poky")
        self.driver.find_element_by_id("search-button").click()
        self.find_element_by_link_text_in_table('otable', 'Variable').click()
        head_list = self.get_table_head_text('otable')
        self.assertTrue(head_list == ['Variable', 'Value', 'Set in file', 'Description'], \
                        msg=("head row contents wrong"))
        self.find_element_by_link_text_in_table('otable', 'Variable').click()
        head_list = self.get_table_head_text('otable')
        self.assertTrue(head_list == ['Variable', 'Value', 'Set in file', 'Description'], \
                        msg=("head row contents wrong"))


        ##############
        #  CASE 916  #
        ##############
    def test_916(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        # step 2-3
        self.find_element_by_link_text_in_table('nav', 'Configuration').click()
        self.driver.find_element_by_link_text("BitBake variables").click()
        variable_list = self.get_table_column_text('class', 'variable_name')
        self.assertTrue(is_list_sequenced(variable_list), msg=("list not in order"))
        # step 4
        self.find_element_by_link_text_in_table('otable', 'Variable').click()
        variable_list = self.get_table_column_text('class', 'variable_name')
        self.assertTrue(is_list_inverted(variable_list), msg=("list not inverted"))
        self.find_element_by_link_text_in_table('otable', 'Variable').click()
        # step 5
        # searching won't change the sequentiality
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("lib")
        self.driver.find_element_by_id("search-button").click()
        variable_list = self.get_table_column_text('class', 'variable_name')
        self.assertTrue(is_list_sequenced(variable_list), msg=("list not in order"))


        ##############
        #  CASE 923  #
        ##############
    def test_923(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # Step 2
        # default sequence in "Completed on" column is inverted
        c_list = self.get_table_column_text('class', 'completed_on')
        self.assertTrue(is_list_inverted(c_list), msg=("list not inverted"))
        # step 3
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.driver.find_element_by_id("checkbox-time").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        head_list = self.get_table_head_text('allbuildstable')
        for item in ['Outcome', 'Recipe', 'Machine', 'Started on', 'Completed on', 'Failed tasks', 'Errors', 'Warnings', 'Time', "Image files", "Project"]:
            self.failUnless(item in head_list, msg=item+' is missing from table head.')

        ##############
        #  CASE 924  #
        ##############
    def test_924(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # Please refer to case 924 requirement
        # default sequence in "Completed on" column is inverted
        c_list = self.get_table_column_text('class', 'completed_on')
        self.assertTrue(is_list_inverted(c_list), msg=("list not inverted"))
        # Step 4
        # click Errors , order in "Completed on" should be disturbed. Then hide
        # error column to check if order in "Completed on" can be restored
        #THIS TEST IS NO LONGER VALID DUE TO DESIGN CHANGES. LEAVING IN PENDING UPDATES TO DESIGN
        self.find_element_by_link_text_in_table('allbuildstable', 'Errors').click()
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("checkbox-errors_no").click()
        self.driver.find_element_by_id("checkbox-failed_tasks").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        # Note: without time.sleep here, there'll be unpredictable error..TBD
        time.sleep(1)
        c_list = self.get_table_column_text('class', 'completed_on')
        self.assertTrue(is_list_inverted(c_list), msg=("list not inverted"))


        ##############
        #  CASE 940  #
        ##############
    def test_940(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        # Step 2-3
        self.find_element_by_link_text_in_table('nav', 'Packages').click()
        check_head_list = ['Package', 'Package version', 'Size', 'Recipe']
        head_list = self.get_table_head_text('otable')
        self.assertTrue(head_list == check_head_list, msg=("head row not as expected"))
        # Step 4
        # pulldown menu
        option_ids = ['recipe__layer_version__layer__name', 'recipe__layer_version__branch', \
                      'recipe__layer_version__layer__commit', 'license', 'recipe__version']
        self.driver.find_element_by_id("edit-columns-button").click()
        for item in option_ids:
            if not self.driver.find_element_by_id(item).is_selected():
                self.driver.find_element_by_id(item).click()
        self.driver.find_element_by_id("edit-columns-button").click()
        # save screen here to observe that 'Package' and 'Package version' is
        # not selectable
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step4')


        ##############
        #  CASE 941  #
        ##############
    def test_941(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        # Step 2-3
        self.find_element_by_link_text_in_table('nav', 'Packages').click()
        # column -- Package
        column_list = self.get_table_column_text_by_column_number('otable', 1)
        self.assertTrue(is_list_sequenced(column_list), msg=("list not in order"))
        self.find_element_by_link_text_in_table('otable', 'Size').click()


        ##############
        #  CASE 942  #
        ##############
    def test_942(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.driver.find_element_by_link_text("Packages").click()
        #get initial table header
        head_list = self.get_table_head_text('otable')
        #remove the Recipe column from table header
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("recipe__name").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        #get modified table header
        new_head = self.get_table_head_text('otable')
        self.assertTrue(head_list > new_head)

        ##############
        #  CASE 943  #
        ##############
    def test_943(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.driver.find_element_by_link_text("Packages").click()
        #search for the "bash" package -> this should definitely be present
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("bash")
        self.driver.find_element_by_id("search-button").click()
        #check for the search result message "XX packages found"
        self.assertTrue(self.is_text_present("packages found"), msg=("no packages found text"))


        ##############
        #  CASE 944  #
        ##############
    def test_944(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()


        dict_key_id = {'Recipes':["layer_version__branch", "layer_version__layer__commit"] , \
                        'Packages':["recipe__layer_version__layer__name", "recipe__layer_version__branch",  "recipe__layer_version__layer__commit"] ,\
                        'core-image-minimal':["layer_name", "layer_branch",  "layer_commit"]}

        layer_list = ["Layer", "Layer branch", "Layer commit"]
        # step 1,2,3: test Recipes, Packages, core-image-minimal page stuff
        for item in dict_key_id:
            print item
            self.driver.find_element_by_link_text(item).click()
            # for these 3 items, default status is not-checked
            self.driver.find_element_by_id("edit-columns-button").click()
            for i in dict_key_id[item]:
                self.driver.find_element_by_id(i).click()
            self.driver.find_element_by_id("edit-columns-button").click()
            # otable is the recipes table here
            otable_head_text = self.get_table_head_text('otable')
            for itm in layer_list:
                self.failIf(itm not in otable_head_text, msg=itm+' not in table head.')
            # click the fist recipe, whatever it is
            self.get_table_element("otable", 1, 1).click()
            if item == 'Recipes':
                self.assertTrue(self.is_text_present(layer_list + ["Recipe file"]), \
                                msg=("text not in web page"))
            else:
                self.assertTrue(self.is_text_present(layer_list), \
                                msg=("text not in web page"))

            self.driver.back()
            self.browser_delay()

        # step 4: check Configuration page
        #self.driver.back()
        self.driver.find_element_by_link_text("Configuration").click()
        otable_head_text = self.get_table_head_text()
        self.assertTrue(self.is_text_present(layer_list), \
                        msg=("text not in web page"))


        ##############
        #  CASE 945  #
        ##############
    def test_945(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        #option_tobeselected = 3
        for item in ["Packages", "Recipes", "Tasks"]:
            print item
            self.driver.get(self.base_url)
            self.driver.find_element_by_link_text("core-image-minimal").click()
            self.driver.find_element_by_link_text(item).click()

            # this may be page specific. If future page content changes, try to replace it with new xpath
            xpath_showrows = "/html/body/div[4]/div/div/div[2]/div[2]/div[2]/div/div/div[2]/select"
            xpath_table = "html/body/div[4]/div/div/div[2]/div[2]/table/tbody"#"id=('otable')/tbody"
            time.sleep(5)

            #self.driver.find_element_by_xpath(xpath_showrows).click()
            Select(self.driver.find_element_by_xpath(xpath_showrows)).select_by_value('50')
            time.sleep(4)
            rows_displayed = int(self.driver.find_element_by_xpath(xpath_showrows + "/option[2]").text)
            print 'rows='
            print rows_displayed

            # not sure if this is a Selenium Select bug: If page is not refreshed here, "select(by visible text)" operation will go back to 100-row page
            # Sure we can use driver.get(url) to refresh page, but since page will vary, we use click link text here

            self.driver.find_element_by_link_text(item).click()
            Select(self.driver.find_element_by_css_selector("select.pagesize")).select_by_visible_text(str(rows_displayed))

            self.failUnless(self.is_element_present(By.XPATH, xpath_table + "/tr[" + str(rows_displayed) +"]"))
            #.//*[@id=str(rows_displayed)]/td[1]/a

            self.failIf(self.is_element_present(By.XPATH, xpath_table + "/tr[" + str(rows_displayed+1) +"]"))
            # click 1st package, then go back to check if it's still those rows shown.
            self.driver.find_element_by_xpath(xpath_table + "/tr[1]/td[1]/a").click()
            time.sleep(3)
            self.driver.find_element_by_link_text(item).click()
            self.assertTrue(self.is_element_present(By.XPATH, xpath_table + "/tr[" + str(rows_displayed) +"]"),\
                            msg=("Row %d should exist" %rows_displayed))

            self.assertFalse(self.is_element_present(By.XPATH, xpath_table + "/tr[" + str(rows_displayed+1) +"]"),\
                            msg=("Row %d should not exist" %(rows_displayed+1)))


        ##############
        #  CASE 946  #
        ##############
    def test_946(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.driver.find_element_by_link_text("Configuration").click()
        # step 3-4
        check_list = ["Summary", "BitBake variables"]
        for item in check_list:
            if not self.is_element_present(how=By.LINK_TEXT, what=item):
                self.log.error("%s not found" %item)
        if not self.is_text_present(['Layers', 'Layer', 'Layer branch', 'Layer commit']):
            self.log.error("text not found")
        # step 5
        self.driver.find_element_by_link_text("BitBake variables").click()
        if not self.is_text_present(['Variable', 'Value', 'Set in file', 'Description']):
            self.log.error("text not found")
        # This may be unstable because it's page-specific
        # step 6: this is how we find filter beside "Set in file"
        temp_element = self.find_element_by_text_in_table('otable', "Set in file")
        temp_element.find_element_by_xpath("..//*/a/i[@class='icon-filter filtered']").click()
        self.browser_delay()
        self.driver.find_element_by_xpath("(//input[@name='filter'])[3]").click()
        btns = self.driver.find_elements_by_css_selector("button.btn.btn-primary")
        for btn in btns:
            try:
                btn.click()
                break
            except:
                pass
        # save screen here
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step6')
        self.driver.find_element_by_id("edit-columns-button").click()
        # save screen here
        # step 7
        # we should manually check the step 6-8 result using screenshot
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step7')
        self.driver.find_element_by_id("edit-columns-button").click()
        # step 9
        # click the 1st item, no matter what it is
        self.driver.find_element_by_xpath("//*[@id='otable']/tbody/tr[1]/td[1]/a").click()
        # give it 1 sec so the pop-up becomes the "active_element"
        time.sleep(1)
        element = self.driver.switch_to.active_element
        check_list = ['Order', 'Configuration file', 'Operation', 'Line number']
        for item in check_list:
            if item not in element.text:
                self.log.error("%s not found" %item)
        # any better way to close this pop-up? ... TBD
        element.find_element_by_class_name("close").click()
        # step 10 : need to manually check "Yocto Manual" in saved screen
        time.sleep(1)
        self.driver.find_element_by_css_selector("i.icon-share.get-info").click()
        # save screen here
        time.sleep(5)
        self.save_screenshot(screenshot_type='native', append_name='step10')


        ##############
        #  CASE 947  #
        ##############
    def test_947(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'Configuration').click()
        # step 2
        self.driver.find_element_by_link_text("BitBake variables").click()
        # step 3
        def xpath_option(column_name):
            # return xpath of options under "Edit columns" button
            return self.shortest_xpath('id', 'navTab') + self.shortest_xpath('id', 'editcol') \
                + self.shortest_xpath('id', column_name)
        self.driver.find_element_by_id('edit-columns-button').click()
        # by default, option "Description" and "Set in file" were checked
        self.driver.find_element_by_xpath(xpath_option('description')).click()
        self.driver.find_element_by_xpath(xpath_option('file')).click()
        self.driver.find_element_by_id('edit-columns-button').click()
        check_list = ['Description', 'Set in file']
        head_list = self.get_table_head_text('otable')
        for item in check_list:
            self.assertFalse(item in head_list, msg=("item %s should not be in head row" % item))
        # check these 2 options and verify again
        self.driver.find_element_by_id('edit-columns-button').click()
        self.driver.find_element_by_xpath(xpath_option('description')).click()
        self.driver.find_element_by_xpath(xpath_option('file')).click()
        self.driver.find_element_by_id('edit-columns-button').click()
        head_list = self.get_table_head_text('otable')
        for item in check_list:
            self.assertTrue(item in head_list, msg=("item %s not in head row" % item))


        ##############
        #  CASE 948  #
        ##############
    def test_948(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'Configuration').click()
        self.driver.find_element_by_link_text("BitBake variables").click()
        #get number of variables visible by default
        number_before_search = self.driver.find_element_by_class_name('page-header').text
        # search for a while...
        self.driver.find_element_by_id("search").clear()
        self.driver.find_element_by_id("search").send_keys("BB")
        self.driver.find_element_by_id("search-button").click()
        #get number of variables visible after search
        number_after_search = self.driver.find_element_by_class_name('page-header').text
        self.assertTrue(number_before_search > number_after_search, msg=("items should be less after search"))


        ##############
        #  CASE 949  #
        ##############
    def test_949(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        self.find_element_by_link_text_in_table('nav', 'core-image-minimal').click()
        # step 3
        try:
            self.driver.find_element_by_partial_link_text("Packages included")
            self.driver.find_element_by_partial_link_text("Directory structure")
        except Exception,e:
            self.log.error(e)
            self.assertFalse(True)
        # step 4
        head_list = self.get_table_head_text('otable')
        for item in ['Package', 'Package version', 'Size', 'Dependencies', 'Reverse dependencies', 'Recipe']:
            self.assertTrue(item in head_list, msg=("item %s not in head row" % item))
        # step 5-6
        self.driver.find_element_by_id("edit-columns-button").click()
        selectable_class = 'checkbox'
        # minimum-table : means unselectable items
        unselectable_class = 'checkbox muted'
        selectable_check_list = ['Dependencies', 'Layer', 'Layer branch', 'Layer commit', \
                                 'License', 'Recipe', 'Recipe version', 'Reverse dependencies', \
                                 'Size', 'Size over total (%)']
        unselectable_check_list = ['Package', 'Package version']
        selectable_list = list()
        unselectable_list = list()
        selectable_elements = self.driver.find_elements_by_xpath("//*[@id='editcol']//*[@class='" + selectable_class + "']")
        unselectable_elements = self.driver.find_elements_by_xpath("//*[@id='editcol']//*[@class='" + unselectable_class + "']")
        for element in selectable_elements:
            selectable_list.append(element.text)
        for element in unselectable_elements:
            unselectable_list.append(element.text)
        # check them
        for item in selectable_check_list:
            self.assertTrue(item in selectable_list, msg=("%s not found in dropdown menu" % item))
        for item in unselectable_check_list:
            self.assertTrue(item in unselectable_list, msg=("%s not found in dropdown menu" % item))
        self.driver.find_element_by_id("edit-columns-button").click()
        # step 7
        self.driver.find_element_by_partial_link_text("Directory structure").click()
        head_list = self.get_table_head_text('dirtable')
        for item in ['Directory / File', 'Symbolic link to', 'Source package', 'Size', 'Permissions', 'Owner', 'Group']:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))

        ##############
        #  CASE 950  #
        ##############
    def test_950(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # step3&4: so far we're not sure if there's "successful build" or "failed
        # build".If either of them doesn't exist, we can still go on other steps
        check_list = ['Configuration', 'Tasks', 'Recipes', 'Packages', 'Time', 'CPU usage', 'Disk I/O']
        has_successful_build = 1
        has_failed_build = 1
        try:
            pass_icon = self.driver.find_element_by_xpath("//*[@class='icon-ok-sign success']")
        except Exception:
            self.log.info("no successful build exists")
            has_successful_build = 0
            pass
        if has_successful_build:
            pass_icon.click()
            # save screen here to check if it matches requirement.
            self.browser_delay()
            self.save_screenshot(screenshot_type='selenium', append_name='step3_1')
            for item in check_list:
                try:
                    self.find_element_by_link_text_in_table('nav', item)
                except Exception:
                    self.assertFalse(True, msg=("link  %s cannot be found in the page" % item))
            # step 6
            check_list_2 = ['Packages included', 'Total package size', \
                      'License manifest', 'Image files']
            self.assertTrue(self.is_text_present(check_list_2), msg=("text not in web page"))
            self.driver.back()
        try:
            fail_icon = self.driver.find_element_by_xpath("//*[@class='icon-minus-sign error']")
        except Exception:
            has_failed_build = 0
            self.log.info("no failed build exists")
            pass
        if has_failed_build:
            fail_icon.click()
            # save screen here to check if it matches requirement.
            self.browser_delay()
            self.save_screenshot(screenshot_type='selenium', append_name='step3_2')
            for item in check_list:
                try:
                    self.find_element_by_link_text_in_table('nav', item)
                except Exception:
                    self.assertFalse(True, msg=("link  %s cannot be found in the page" % item))
            # step 7 involved
            check_list_3 = ['Machine', 'Distro', 'Layers', 'Total number of tasks', 'Tasks executed', \
                      'Tasks not executed', 'Reuse', 'Recipes built', 'Packages built']
            self.assertTrue(self.is_text_present(check_list_3), msg=("text not in web page"))
            self.driver.back()


        ##############
        #  CASE 951  #
        ##############
    def test_951(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # currently test case itself isn't responsible for creating "1 successful and
        # 1 failed build"
        has_successful_build = 1
        has_failed_build = 1
        try:
            fail_icon = self.driver.find_element_by_xpath("//*[@class='icon-minus-sign error']")
        except Exception:
            has_failed_build = 0
            self.log.info("no failed build exists")
            pass
        # if there's failed build, we can proceed
        if has_failed_build:
            self.driver.find_element_by_partial_link_text("error").click()
            self.driver.back()
        # not sure if there "must be" some warnings, so here save a screen
        self.browser_delay()
        self.save_screenshot(screenshot_type='selenium', append_name='step4')


        ##############
        #  CASE 955  #
        ##############
    def test_955(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.log.info(" You should manually create all images before test starts!")
        # So far the case itself is not responsable for creating all sorts of images.
        # So assuming they are already there
        # step 2
        self.driver.find_element_by_link_text("core-image-minimal").click()
        # save screen here to see the page component


        ##############
        #  CASE 956  #
        ##############
    def test_956(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        # step 2-3 need to run manually
        self.log.info("step 2-3: checking the help message when you hover on help icon of target,\
                       tasks, recipes, packages need to run manually")
        self.driver.find_element_by_partial_link_text("Manual").click()
        if not self.is_text_present("Manual"):
            self.log.error("please check [Toaster manual] link on page")
            self.failIf(True)


        ##############
        #  CASE 1069 #
        ##############
    def test_1069(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        layer_list = ['Layer', 'Summary', 'Git revision', 'Dependencies', 'Add | Remove']
        self.driver.find_element_by_partial_link_text("Layers").click()
        time.sleep(1)

        # step 3
        self.driver.find_element_by_id('search-input-layerstable').send_keys('meta-yocto')
        time.sleep(1)
        self.driver.find_element_by_id('search-submit-layerstable').click()
        time.sleep(1)

        self.assertTrue(self.driver.find_element_by_partial_link_text('meta-yocto'), msg=("meta-yocto layer not find"))
        self.assertTrue(self.driver.find_element_by_partial_link_text('meta-yocto-bsp'), msg=("meta-yocto-bsp layer not find"))
        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-submit-layerstable").click()

        head_list = self.get_table_head_text('layerstable')
        time.sleep(1)
        for item in layer_list:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))

        #step 5
        layer_revision = self.driver.find_elements_by_class_name('revision')
        layer_rev = layer_revision[1].text
        self.driver.find_element_by_partial_link_text('Configuration').click()
        time.sleep(1)
        revision = self.driver.find_element_by_id("project-release-title").text
        self.assertTrue(layer_rev in revision, msg=("revision difference"))
        self.driver.find_element_by_partial_link_text("Layers").click()

        #step 6-7
        self.driver.find_element_by_id("search-input-layerstable").send_keys('e100-bsp')
        self.driver.find_element_by_id("search-submit-layerstable").click()
        time.sleep(1)
        self.assertTrue(self.driver.find_element_by_xpath(".//*[@id='layerstable']/tbody/tr/td[6]/a"), msg="no dependencies button")
        self.driver.find_element_by_xpath(".//*[@id='layerstable']/tbody/tr/td[6]/a").click()
        time.sleep(2)

        #step 8
        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-submit-layerstable").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("checkbox-layer__vcs_url").click()
        self.driver.find_element_by_id("checkbox-git_subdir").click()
        time.sleep(2)
        self.assertTrue(self.driver.find_element_by_xpath(".//*[@id='layerstable']/tbody/tr[1]/td[3]/a[2]/i"), msg="git repository url not found")
        self.assertTrue(self.driver.find_element_by_xpath(".//*[@id='layerstable']/tbody/tr[1]/td[4]/a[2]/i"), msg="subdirectory url not found")
        time.sleep(2)


        ##############
        #  CASE 1070 #
        ##############
    def test_1070(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        columns = ['layer__name', 'layer__summary', 'layer__vcs_url', 'git_subdir', 'revision', 'dependencies', 'add-del-layers']
        time.sleep(1)
        self.driver.find_element_by_id("view-compatible-layers").click()
        time.sleep(1)

        #step 3
        element = self.driver.find_element_by_css_selector('th.layer__name')
        self.assertTrue("i class=\"icon-caret-down\" style=\"display: inline;\"" in element.get_attribute('innerHTML'), msg='Table not sorted by layer')

        #step 4
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-layer__vcs_url").click()
        self.driver.find_element_by_id("checkbox-git_subdir").click()

        self.driver.find_element_by_id("edit-columns-button").click()

        #step 5
        for column in columns:
            element = self.driver.find_element_by_css_selector('th.%s' % column)
            if column == 'layer__name':
                self.assertTrue("a class=\"sorted\"" in element.get_attribute('innerHTML'), msg='%s column is sortable' %column)
            else:
                self.assertFalse("a class=\"sorted\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)

        #step 6-7
        self.driver.find_element_by_xpath("//*[@id='layerstable']/thead/th[1]/a").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("meta-intel")
        self.driver.find_element_by_id("search-submit-layerstable").click()
        time.sleep(2)

        elements = self.driver.find_elements_by_xpath("//td[@class='layer__name']")
        values = [element.text for element in elements]

        if is_list_inverted(values):
            self.driver.find_element_by_xpath("//*[@id='layerstable']/thead/th[1]/a").click()
            time.sleep(2)
            elements = self.driver.find_elements_by_xpath("//td[@class='layer__name']")
            values = [element.text for element in elements]
            self.assertTrue(is_list_sequenced(values), msg=("Layer column not in order" ))
        else:
            self.assertTrue(is_list_sequenced(values), msg=("Layer column not sequenced"))
            self.driver.find_element_by_xpath("//*[@id='layerstable']/thead/th[1]/a").click()
            time.sleep(2)
            elements = self.driver.find_elements_by_xpath("//td[@class='layer__name']")
            values = [element.text for element in elements]
            self.assertTrue(is_list_inverted(values), msg=("Layer column not inverted" ))

        selected_layer = values[0]
        self.driver.find_element_by_partial_link_text(selected_layer).click()
        time.sleep(1)
        self.driver.back()
        time.sleep(2)

        elements = self.driver.find_elements_by_xpath("//td[@class='layer__name']")
        values2 = [element.text for element in elements]
        self.assertEqual(values, values2, "Layer column is not sorted properly")
        time.sleep(3)


        ##############
        #  CASE 1073 #
        ##############
    def test_1073(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        layer_list = ['Layer', 'Summary', 'Subdirectory', 'Git repository URL','Git revision', 'Dependencies', 'Add | Remove']
        time.sleep(1)
        self.driver.find_element_by_id("view-compatible-layers").click()
        time.sleep(1)

        # step 3
        self.assertTrue(self.driver.find_element_by_id("search-input-layerstable"), "Search input not found")
        self.assertTrue(self.driver.find_element_by_id("search-submit-layerstable"), " Search button not found")
        all_layers = self.driver.find_element_by_class_name("table-count-layerstable").text

        # step 4
        self.assertEqual("Search compatible layers", self.driver.find_element_by_id("search-input-layerstable").get_attribute("placeholder") \
                         ,"Different placeholder text")

        # step 5
        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("c")
        self.assertEqual("c",self.driver.find_element_by_id("search-input-layerstable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("core")
        self.driver.find_element_by_id("search-submit-layerstable").click()
        time.sleep(2)

        # step 6
        # returned results
        self.assertEqual("core",self.driver.find_element_by_id("search-input-layerstable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        layers_after_search = self.driver.find_element_by_class_name("table-count-layerstable").text
        self.assertNotEqual(all_layers,layers_after_search, msg="Same compatibles layers")

        self.driver.find_element_by_xpath("//*[@id='table-chrome-layerstable']/div/div[1]/a/i").click()
        time.sleep(2)

        layers_after_clear_search = self.driver.find_element_by_class_name("table-count-layerstable").text
        self.assertEqual(all_layers, layers_after_clear_search, msg="Different number of compatibles layers")

        #no results
        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("dkasashdsakjdhasjkdashdjk")
        self.driver.find_element_by_id("search-submit-layerstable").click()

        time.sleep(2)

        no_layers = self.driver.find_element_by_class_name("table-count-layerstable").text
        if no_layers=="0":
            self.driver.find_element_by_xpath("//*[@id='no-results-layerstable']/div/form/button[2]").click()
            time.sleep(2)
            layers_show_all = self.driver.find_element_by_class_name("table-count-layerstable").text
            self.assertEqual(all_layers, layers_show_all, msg="Different number of compatibles layers")
        else:
            self.fail(msg='Search is not working properly')

        # step 7
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("checkbox-layer__vcs_url").click()
        self.driver.find_element_by_id("checkbox-git_subdir").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("core")
        self.driver.find_element_by_id("search-submit-layerstable").click()
        time.sleep(2)

        head_list = self.get_table_head_text('layerstable')
        for item in layer_list:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))

        # step 8
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        self.driver.find_element_by_id("in_current_project").click()
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("core")
        self.driver.find_element_by_id("search-submit-layerstable").click()

        time.sleep(2)
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        # bug 8125
        self.driver.find_element_by_id("in_current_project").click()
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_xpath(".//*[@id='table-chrome-layerstable']/div/div[1]/a/i").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied after remove search - bug 8125")

        ##############
        #  CASE 1078 #
        ##############
    def test_1078(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        initial_layers = self.get_list_elements("layers-in-project-list")
        self.driver.find_element_by_id("view-compatible-layers").click()
        time.sleep(1)

        #step 3
        head_list = self.get_table_head_text('layerstable')
        self.assertTrue('Add | Remove' in head_list, msg=("Add | Remove not found in Directory structure table head"))

        # sep 4
        layer = "meta-intel-iot-devkit"
        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys(layer)
        self.driver.find_element_by_id("search-submit-layerstable").click()

        time.sleep(3)
        if layer in initial_layers:
            remove_layer = self.driver.find_elements_by_css_selector("i.icon-trash")
            remove_layer[0].click()

        time.sleep(2)
        add_layer = self.driver.find_elements_by_css_selector("i.icon-plus")
        add_layer[0].click()

        time.sleep(1)
        dependecies_layers = self.get_list_elements("dependencies-list")
        avail_options = self.driver.find_elements_by_xpath("//*[@id='dependencies-list']//*[@class='checkbox']")

        unselected_layer = avail_options[0].text
        avail_options[0].click()
        time.sleep(2)
        dependecies_layers.pop(0)
        time.sleep(1)

        # click Add layers
        self.driver.find_element_by_xpath("//*[@id='dependencies-modal-form']//*[@type='submit']").click()
        time.sleep(1)
        message = self.driver.find_element_by_id("change-notification-msg").text

        layers_added = dependecies_layers
        layers_added.append(layer)

        nr_layers=str(len(layers_added))
        self.assertIn(nr_layers,message, "Different number layer in message %s " %nr_layers)

        for elem in layers_added:
            self.assertIn(elem, message, "Layer %s not found " %elem)

        self.driver.find_element_by_partial_link_text('Configuration').click()
        time.sleep(2)

        project_layers = self.get_list_elements("layers-in-project-list")
        self.assertNotIn(unselected_layer,project_layers, msg="Found unselected layer %s in Project Layers" %unselected_layer)

        expected_layers = initial_layers + layers_added
        self.assertEqual(Counter(expected_layers), Counter(project_layers),msg="Dependencies layers not added to the project")

        self.driver.find_element_by_id("view-compatible-layers").click()
        time.sleep(1)
        for elem in layers_added:
            self.driver.find_element_by_id("search-input-layerstable").clear()
            self.driver.find_element_by_id("search-input-layerstable").send_keys(elem)
            self.driver.find_element_by_id("search-submit-layerstable").click()
            time.sleep(1)

            remove_layer = self.driver.find_elements_by_css_selector("i.icon-trash")
            for index in range(0, len(remove_layer)):
                try:
                    remove_layer[index].click()
                except:
                    print index

            time.sleep(1)

            message = self.driver.find_element_by_id("change-notification-msg").text

            self.assertIn(elem, message, msg="Different layer removed: %s" %elem)
            self.assertIn('removed', message, msg="Not found removed in notification message")

        self.driver.find_element_by_partial_link_text('Configuration').click()
        time.sleep(2)

        project_layers = self.get_list_elements("layers-in-project-list")

        for item in layers_added:
            self.assertTrue(item not in project_layers, msg=("%s layer found in project layers after remove" % item))


        ##############
        #  CASE 1079 #
        ##############
    def test_1079(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        default_image_list = ['Image recipe', 'Version', 'Description', 'Layer', 'Build']
        time.sleep(0.5)

        #step 3
        self.driver.find_element_by_link_text("Image recipes").click()
        time.sleep(0.5)

        #step 4
        l = self.get_table_data('imagerecipestable', 10, 5)
        self.assertTrue(l != [], msg="Image recipes table is not populated")

        head_list = self.get_table_head_text('imagerecipestable')
        for item in default_image_list:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))


        ##############
        #  CASE 1080 #
        ##############
    def test_1080(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        image_recipes_sortable_dict = {'Image recipe':'name', 'Section':'section', 'Layer':'layer_version__layer__name', 'License':'license'}
        image_recipes_not_sortable_dict = {'Version':'version', 'Description':'get_description_or_summary', 'Recipe file':'recipe-file', \
                                           'Git revision':'layer_version__get_vcs_reference', 'Build':'add-del-layers'}
        time.sleep(0.5)

        #step 2
        self.driver.find_element_by_link_text("Image recipes").click()
        time.sleep(0.5)

        #step 3
        element = self.driver.find_element_by_css_selector('th.name')
        self.assertTrue("i class=\"icon-caret-down\" style=\"display: inline;\"" in element.get_attribute('innerHTML'),\
                        msg='Table not sorted by Image recie')

        #step 4
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-recipe-file").click()
        self.driver.find_element_by_id("checkbox-section").click()
        self.driver.find_element_by_id("checkbox-license").click()
        self.driver.find_element_by_id("checkbox-layer_version__get_vcs_reference").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()

        #step 5
        for column in image_recipes_sortable_dict:
            element = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict[column])
            time.sleep(1)
            if column == 'Image recipe':
                self.assertTrue("a class=\"sorted\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)
            else:
                self.assertTrue("href=\"#\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)

        for column in image_recipes_not_sortable_dict:
            element = self.driver.find_element_by_css_selector('th.%s' %image_recipes_not_sortable_dict[column])
            time.sleep(1)
            self.assertTrue("<span class=\"muted\">" in element.get_attribute('innerHTML'), msg='%s column is sortable' %column)

        #step 6
        e = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict['Image recipe'])
        e.click()
        time.sleep(1)
        self.assertTrue("<i class=\"icon-caret-up\"" in e.get_attribute('innerHTML'),\
                        msg='Image recipe is not sorted descendent')
        time.sleep(1)

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("meta-intel")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()
        time.sleep(1)

        #step 8
        e = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict['Image recipe'])
        self.assertTrue("<i class=\"icon-caret-up\"" in e.get_attribute('innerHTML'),\
                        msg='Image recipe is not sorted descendent after search')

        #continue step 6
        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        values = [element.text for element in elements]

        selected_recipe = values[0]
        self.driver.find_element_by_partial_link_text(selected_recipe).click()
        time.sleep(1)
        self.driver.back()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        values2 = [element.text for element in elements]
        self.assertEqual(values, values2, "Image Recipe column is not sorted properly")

        #step 7
        element = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict['Section'])
        element.click()
        time.sleep(1)
        self.assertTrue("a class=\"sorted\"" in element.get_attribute('innerHTML'), msg='Table is not sort by Section')
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-section").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        values3 = [element.text for element in elements]
        invers = list(reversed(values))
        self.assertEqual(invers, values3, msg="Default sorting was not restore")


        ##############
        #  CASE 1081 #
        ##############
    def test_1081(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        target_list = ['Image recipe', 'Version', 'Description', 'Recipe file', 'Section', 'Layer', 'License', \
                       'Git revision', 'Build']
        time.sleep(1)

        #step 2
        self.driver.find_element_by_link_text("Image recipes").click()
        time.sleep(1)

        # step 3
        self.assertTrue(self.driver.find_element_by_id("search-input-imagerecipestable"), "Search input not found")
        self.assertTrue(self.driver.find_element_by_id("search-submit-imagerecipestable"), " Search button not found")
        all_targets = self.driver.find_element_by_class_name("table-count-imagerecipestable").text

        # step 4
        self.assertEqual("Search compatible image recipes", \
                         self.driver.find_element_by_id("search-input-imagerecipestable").get_attribute("placeholder") \
                         ,"Different placeholder text")

        # step 5
        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("c")
        self.assertEqual("c",self.driver.find_element_by_id("search-input-imagerecipestable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()
        time.sleep(2)

        # step 6
        # returned results
        self.assertEqual("core", self.driver.find_element_by_id("search-input-imagerecipestable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        targets_after_search = self.driver.find_element_by_class_name("table-count-imagerecipestable").text
        self.assertNotEqual(all_targets, targets_after_search, msg="Same compatibles targets")

        self.driver.find_element_by_xpath("//*[@id='table-chrome-imagerecipestable']/div/div[1]/a/i").click()
        time.sleep(2)

        targets_after_clear_search = self.driver.find_element_by_class_name("table-count-imagerecipestable").text
        self.assertEqual(all_targets, targets_after_clear_search, msg="Different number of compatibles targets")

        #no results
        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("dkasashdsakjdhasjkdashdjk")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()

        time.sleep(3)
        no_targets = self.driver.find_element_by_class_name("table-count-imagerecipestable").text
        if no_targets=="0":
            self.driver.find_element_by_xpath("//*[@id='no-results-imagerecipestable']/div/form/button[2]").click()
            time.sleep(2)
            targets_show_all = self.driver.find_element_by_class_name("table-count-imagerecipestable").text
            self.assertEqual(all_targets, targets_show_all, msg="Different number of compatibles targets")
        else:
            self.fail(msg='Search is not working properly')

        # step 7
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-recipe-file").click()
        self.driver.find_element_by_id("checkbox-section").click()
        self.driver.find_element_by_id("checkbox-license").click()
        self.driver.find_element_by_id("checkbox-layer_version__get_vcs_reference").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()
        time.sleep(1)

        head_list = self.get_table_head_text('imagerecipestable')
        for item in target_list:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))

        # step 8
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        self.driver.find_element_by_id("in_current_project").click()
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()

        time.sleep(2)
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        # bug 8125
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_xpath(".//*[@id='table-chrome-imagerecipestable']/div/div[1]/a/i").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied after remove search - bug 8125")


        ##############
        #  CASE 1094 #
        ##############
    def test_1094(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_id("view-compatible-layers").click()
        time.sleep(1)

        # step 3
        add_remove_element = self.driver.find_element_by_class_name("add-del-layers")
        self.assertIn("<i class=\"icon-filter filtered\"></i>", add_remove_element.get_attribute('innerHTML'), \
                      msg='Add|Remove filter dose not exist')

        # step 4
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:not_in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:all").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        # step 5
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("core")
        self.driver.find_element_by_id("search-submit-layerstable").click()

        time.sleep(2)
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        ##############
        #  CASE 1095 #
        ##############
    def test_1095(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_link_text("Image recipes").click()
        time.sleep(1)

        # step 3
        build_element = self.driver.find_element_by_class_name("add-del-layers")
        self.assertIn("<i class=\"icon-filter filtered\"></i>", build_element.get_attribute('innerHTML'), \
                      msg='Build filter dose not exist')

        # step 4
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:not_in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:all").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        # step 5
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()

        time.sleep(2)
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")


        ##############
        #  CASE 1104 #
        ##############
    def test_1104(self):
            self.case_no = self.get_case_number()
            self.log.info(' CASE %s log: ' % str(self.case_no))
            self.driver.maximize_window()
            self.driver.get(self.base_url)

            self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
            time.sleep(1)
            self.driver.find_element_by_link_text("selenium-project").click()
            time.sleep(1)

            #step 4
            builds = self.driver.find_element_by_partial_link_text("Builds (").text
            nr_builds = int(filter(str.isdigit, repr(builds)))
            self.driver.find_element_by_link_text(builds).click()
            time.sleep(2)

            # Step 5
            default_head_table = ['Outcome', 'Recipe', 'Completed on', 'Failed tasks', 'Errors', 'Warnings', "Image files"]
            head_list = self.get_table_head_text('projectbuildstable')
            for item in default_head_table :
                self.failUnless(item in head_list, msg=item+' is missing from table head.')

            icon_up = self.driver.find_element_by_xpath("//*[@class='completed_on']//*[@class='icon-caret-up']").get_attribute('style')

            self.assertIn("inline", icon_up ,msg = "Icon for completed on is down")
            selector = "td[class='completed_on']"
            column_list = self.get_text_from_elements(selector)

            self.assertTrue(is_list_inverted(column_list), msg="Table is not sorted by Completed on column in descending order")


        ##############
        #  CASE 1105 #
        ##############
    def test_1105(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        project_builds_sortable_dict = {'Outcome':'outcome', 'Machine':'machine', 'Completed on':'completed_on', \
                                        'Errors':'errors_no','Warnings':'warnings_no'}
        project_builds_not_sortable_dict = {'Recipe':'target', 'Failed tasks':'failed_tasks', 'Time':'time', \
                                        'Image files':'image_files'}
        time.sleep(1)
        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)

        # step 3
        element = self.driver.find_element_by_css_selector('th.completed_on')
        self.assertTrue("i class=\"icon-caret-up\" style=\"display: inline;\"" in element.get_attribute('innerHTML'), msg='Table not sorted by Image recie')
        time.sleep(1)

        # step 4
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-machine").click()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.driver.find_element_by_id("checkbox-time").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(1)

        # step 5
        for column in project_builds_sortable_dict:
            element = self.driver.find_element_by_css_selector('th.%s' % project_builds_sortable_dict[column])
            time.sleep(1)
            self.assertTrue("<i class=\"icon-caret-down\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)
            self.assertTrue("<i class=\"icon-caret-up\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)
            self.assertTrue("href=\"#\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)

        for column in project_builds_not_sortable_dict:
            element = self.driver.find_element_by_css_selector('th.%s' %project_builds_not_sortable_dict[column])
            time.sleep(1)
            self.assertTrue("<span class=\"muted\">" in element.get_attribute('innerHTML'), msg='%s column is sortable' %column)

        elements = self.driver.find_elements_by_xpath("//td[@class='completed_on']")
        values = [element.text for element in elements]
        print values

        #step 6
        self.driver.find_element_by_xpath(".//*[@id='projectbuildstable']/thead/th[3]/a").click()
        element = self.driver.find_element_by_css_selector('th.%s' % project_builds_sortable_dict['Machine'])
        element.click()
        time.sleep(1)
        self.assertTrue("class=\"sorted\"" in element.get_attribute('innerHTML'), msg='Table is not sort by Machine')
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-machine").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        elements = self.driver.find_elements_by_xpath("//td[@class='completed_on']")
        values2 = [element.text for element in elements]
        self.assertEqual(values, values2, msg="Default sorting was not restore")

        ##############
        #  CASE 1106 #
        ##############
    def test_1106(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)

        # step 3
        head_list = self.get_table_head_text('projectbuildstable')
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(1)
        all_editcolumns_elements = self.get_editcolumns_list_elements_by_class('.dropdown-menu.editcol')

        checked_elements = []
        for element in all_editcolumns_elements:
            if ("checked=\"checked\"" in element.get_attribute('innerHTML')):
                checked_elements.append(element.text)

        self.assertEqual(Counter(head_list), Counter(checked_elements), msg="Checked columns from edit button doesn't "\
                                                                            "match the columns currently being shown")

        # step 4
        for element in all_editcolumns_elements:
            if element.text in ['Outcome', 'Recipe', 'Completed on']:
                self.assertIn('class="checkbox muted"', element.get_attribute('innerHTML'), msg='%s column can be '\
                                                                    'removed from the shown columns' %element.text)

        # step 5
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-machine").click()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.driver.find_element_by_id("checkbox-time").click()
        self.driver.find_element_by_id("edit-columns-button").click()

        time.sleep(0.5)
        head_list = self.get_table_head_text('projectbuildstable')
        for item in ['Machine', 'Started on', 'Time']:
            self.assertIn(item, head_list, msg='%s items is not in table' %item)

        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("checkbox-machine").click()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.driver.find_element_by_id("checkbox-time").click()
        self.driver.find_element_by_id("edit-columns-button").click()

        time.sleep(0.5)
        head_list = self.get_table_head_text('projectbuildstable')
        for item in ['Machine', 'Started on', 'Time']:
            self.assertNotIn(item, head_list, msg='%s items is in table' %item)


        ##############
        #  CASE 1108 #
        ##############
    def test_1108(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()

        time.sleep(1)
        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)

        self.driver.find_element_by_id("edit-columns-button").click()
        self.driver.find_element_by_id("checkbox-started_on").click()
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(1)

        # step 3
        filters = []
        filters.append(self.driver.find_element_by_id("outcome_filter"))
        filters.append(self.driver.find_element_by_id("started_on_filter"))
        filters.append(self.driver.find_element_by_id("completed_on_filter"))
        filters.append(self.driver.find_element_by_id("failed_tasks_filter"))

        for filter in filters:
            self.assertIn("<i class=\"icon-filter filtered\"></i>", filter.get_attribute('innerHTML'), \
                      msg='Filter does not exist')

        # step 4
        outcome = self.driver.find_element_by_id("outcome_filter")
        outcome.click()
        time.sleep(1)
        self.driver.find_element_by_id("outcome_filter:successful_builds").click()
        time.sleep(0.5)
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(1)
        self.assertIn("btn-primary", outcome.get_attribute('class'), msg='Outcome filter was not applied')

        failed_task = self.driver.find_element_by_id("failed_tasks_filter")
        failed_task.click()
        time.sleep(1)
        self.driver.find_element_by_id("failed_tasks_filter:without_failed_tasks").click()
        time.sleep(0.5)
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(1)

        self.assertIn("btn-primary", failed_task.get_attribute('class'), msg='Failed task filter was not applied')
        self.assertNotIn("btn-primary", outcome.get_attribute('class'), msg='Outcome filter is still applied')

        # step 5
        self.driver.find_element_by_id("search-input-projectbuildstable").clear()
        self.driver.find_element_by_id("search-input-projectbuildstable").send_keys("core")
        self.driver.find_element_by_id("search-submit-projectbuildstable").click()

        time.sleep(2)
        for filter in filters:
            self.assertNotIn("btn-primary", filter.get_attribute('class'), msg='Filter is still applied after search')

        ##############
        #  CASE 1109 #
        ##############
    def test_1109(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()

        time.sleep(1)
        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)
        search_string = "core"

        self.assertTrue(self.driver.find_element_by_id("search-input-projectbuildstable"), "Search input not found")
        self.assertTrue(self.driver.find_element_by_id("search-submit-projectbuildstable"), " Search button not found")

        #step 3
        self.assertEqual("Search all project builds", \
                         self.driver.find_element_by_id("search-input-projectbuildstable").get_attribute("placeholder") ,\
                         "Different placeholder text")

        #step 4
        self.driver.find_element_by_id("search-input-projectbuildstable").clear()
        self.driver.find_element_by_id("search-input-projectbuildstable").send_keys("c")
        self.assertEqual("c", self.driver.find_element_by_id("search-input-projectbuildstable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        self.driver.find_element_by_id("search-input-projectbuildstable").clear()
        self.driver.find_element_by_id("search-input-projectbuildstable").send_keys(search_string)
        self.driver.find_element_by_id("search-submit-projectbuildstable").click()
        time.sleep(1)

        self.assertEqual(search_string, self.driver.find_element_by_id("search-input-projectbuildstable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        returned_builds = self.driver.find_element_by_css_selector(".page-header.top-air").text
        nr_builds = int(filter(str.isdigit, repr(returned_builds)))
        self.assertIn("project builds found", returned_builds, msg='Message after search not showing properly')

        self.driver.find_element_by_xpath(".//*[@id='table-chrome-projectbuildstable']/div/div[1]/a/i").click()
        time.sleep(1)
        self.assertIn("All project builds", self.driver.find_element_by_css_selector(".page-header.top-air").text, \
                      msg='Message after search not showing properly')

        #step 5
        self.driver.find_element_by_id("search-input-projectbuildstable").clear()
        self.driver.find_element_by_id("search-input-projectbuildstable").send_keys('dkasashdsakjdhasjkdashdjk')
        self.driver.find_element_by_id("search-submit-projectbuildstable").click()
        time.sleep(1)
        self.assertIn("No project builds found", self.driver.find_element_by_css_selector(".page-header.top-air").text, \
                      msg='Search is not working properly')
        self.driver.find_element_by_xpath(".//*[@id='no-results-projectbuildstable']/div/form/button[2]").click()
        time.sleep(1)

        # step 6
        self.driver.find_element_by_id('edit-columns-button').click()
        self.driver.find_element_by_id('checkbox-started_on').click()
        self.driver.find_element_by_id('edit-columns-button').click()
        time.sleep(1)

        head_list = self.get_table_head_text('projectbuildstable')
        time.sleep(1)

        started_on = self.driver.find_element_by_css_selector('th.started_on')
        self.driver.find_element_by_partial_link_text('Started on').click()
        time.sleep(1)
        self.assertTrue("<a class=\"sorted\" href=\"#\">" in started_on.get_attribute('innerHTML'), \
                        msg='Table not sorted by started on column')

        self.driver.find_element_by_id("search-input-projectbuildstable").clear()
        self.driver.find_element_by_id("search-input-projectbuildstable").send_keys(search_string)
        self.driver.find_element_by_id("search-submit-projectbuildstable").click()
        time.sleep(1)

        element_after_search = self.driver.find_element_by_css_selector('th.started_on')
        self.assertTrue("<a class=\"sorted\" href=\"#\">" in element_after_search.get_attribute('innerHTML'), \
                msg='Table not sorted by started on after search')

        head_list_after_search = self.get_table_head_text('projectbuildstable')
        self.assertEqual(head_list, head_list_after_search, msg='The table have different columns after search')

        ##############
        #  CASE 1393 #
        ##############
    def test_1393(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)
        self.driver.find_element_by_link_text('core-image-minimal').click()
        time.sleep(1)

        #step 6
        self.driver.find_element_by_partial_link_text('Tasks').click()
        time.sleep(1)

        #step 7
        self.driver.find_element_by_xpath(".//*[@id='otable']/thead/tr/th[6]/div/a").click()
        time.sleep(1)
        avail_options = self.driver.find_elements_by_xpath("//*[@id='filter_outcome']//*[@class='radio'][not(@disabled)]")

        for number in range(0, len(avail_options)):
            if avail_options[number].text == 'Succeeded Tasks':
                avail_options[number].click()
                self.browser_delay()
                # click "Apply"
                self.driver.find_element_by_xpath("//*[@id='filter_outcome']//*[@type='submit']").click()
                break
        time.sleep(1)
        try:
            succeeded_tasks = self.driver.find_elements_by_xpath("//td[@class='task_name']/a")
            succeeded_tasks[0].click()
            time.sleep(1)
            # step 8
            task_log = self.driver.find_element_by_css_selector('.btn.btn-large')
            task_log.click()
            time.sleep(1)
            self.assertTrue(task_log.get_attribute('href') != '', msg='Download link is empty!')
            self.assertIn('tasklogfile', task_log.get_attribute('href'), msg='Is not the task log file')
        except:
            print "No succeeded tasks"
            self.find_element_by_text("Show all tasks").click()
            time.sleep(1)

        # step 9
        self.driver.get(self.base_project_url)
        time.sleep(1)
        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)
        self.driver.find_element_by_link_text('core-image-minimal').click()
        time.sleep(1)

        #step 6
        self.driver.find_element_by_partial_link_text('Tasks').click()
        time.sleep(1)

        #step 7
        self.driver.find_element_by_xpath(".//*[@id='otable']/thead/tr/th[6]/div/a").click()
        time.sleep(1)
        avail_options = self.driver.find_elements_by_xpath("//*[@id='filter_outcome']//*[@class='radio'][not(@disabled)]")

        for number in range(0, len(avail_options)):
            if avail_options[number].text == 'Failed Tasks':
                avail_options[number].click()
                self.browser_delay()
                # click "Apply"
                self.driver.find_element_by_xpath("//*[@id='filter_outcome']//*[@type='submit']").click()

                break
        time.sleep(1)
        try:
            failed_tasks = self.driver.find_elements_by_xpath("//td[@class='task_name']/a")
            failed_tasks[0].click()
            time.sleep(1)
            # step 10
            task_log = self.driver.find_element_by_css_selector('.btn.btn-large')
            task_log.click()
            time.sleep(1)
            self.assertTrue(task_log.get_attribute('href') != '', msg='Download link is empty!')
            self.assertIn('tasklogfile', task_log.get_attribute('href'), msg='Is not the task log file')
        except:
            print "No failed tasks"
            self.find_element_by_text("Show all tasks").click()
            time.sleep(1)

        ##############
        #  CASE 1394 #
        ##############
    def test_1394(self):

        self.timeout = 15
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_id('build-input').clear()
        self.driver.find_element_by_id('build-input').send_keys('core-image-minimal:clean')
        self.driver.find_element_by_id('build-button').click()
        time.sleep(1)
        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)

        time.sleep(1)
        self.wait_until_build_finish(1, 15)

        rebuild_elements = self.driver.find_elements_by_css_selector(".btn.btn-success.pull-right")
        for element in rebuild_elements:
            if "core-image-minimal:clean" in element.get_attribute('onclick'):
                element.click()
                break

        time.sleep(1)
        self.wait_until_build_finish(1, 15)

        self.driver.find_element_by_partial_link_text('core-image-minimal:clean').click()
        time.sleep(1)
        nr_of_tasks = self.driver.find_element_by_xpath("//div[@class='well span4 dashboard-section'][2]/dl/dd[1]/a").text
        print nr_of_tasks
        self.assertEqual("1", nr_of_tasks, msg="The number of tasks executed is not 1")

        self.driver.get(self.base_url)
        time.sleep(1)

        rebuild_elements = self.driver.find_elements_by_css_selector(".btn.btn-success.pull-right")
        for element in rebuild_elements:
            if "core-image-minimal:clean" in element.get_attribute('onclick'):
                element.click()
                break

        time.sleep(1)
        self.wait_until_build_finish(1, 15)

        self.driver.find_element_by_partial_link_text('core-image-minimal:clean').click()
        time.sleep(1)
        nr_of_tasks = self.driver.find_element_by_xpath("//div[@class='well span4 dashboard-section'][2]/dl/dd[1]/a").text
        print nr_of_tasks
        self.assertEqual("1", nr_of_tasks, msg="The number of tasks executed is not 1")

        ##############
        #  CASE 1395 #
        ##############
    def test_1395(self):

        self.timeout = 15
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_link_text('Layers').click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-layerstable").clear()
        self.driver.find_element_by_id("search-input-layerstable").send_keys("meta-intel")
        self.driver.find_element_by_id("search-submit-layerstable").click()
        time.sleep(1)

        self.driver.find_element_by_link_text("meta-intel").click()
        time.sleep(1)
        self.driver.find_element_by_id("add-remove-layer-btn").click()
        time.sleep(1)
        self.driver.find_element_by_id("machines-tab").click()

        machines = self.driver.find_elements_by_css_selector(".btn.btn-block.select-machine-btn")
        for machine in machines:
            if "intel-core2-32" in machine.get_attribute("href"):
                machine.click()
                break

        time.sleep(1)
        self.assertIn("intel-core2-32", self.driver.find_element_by_id("project-machine-name").text, msg="Machine was not changed")

        self.driver.find_element_by_id('build-input').clear()
        self.driver.find_element_by_id('build-input').send_keys('core-image-minimal')
        self.driver.find_element_by_id('build-button').click()
        time.sleep(1)

        self.wait_until_build_finish(1, 30)
        self.driver.find_element_by_link_text('core-image-minimal').click()
        time.sleep(1)

        self.driver.find_element_by_link_text("Configuration").click()
        time.sleep(1)


        self.assertIn("meta-intel", self.get_table_data_from_class("table table-bordered table-hover", 4, 1), \
                      msg="meta-intel layer not added to build")

        

        ##############
        #  CASE 1396 #
        ##############
    def test_1396(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()

        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)
        self.driver.find_element_by_link_text('core-image-minimal').click()
        time.sleep(1)

        build_artifact = self.driver.find_element_by_xpath("//dl[@class='dl-horizontal']/dd/div/a[2]")
        build_artifact.click()
        time.sleep(2)

        self.assertTrue(build_artifact.get_attribute('href') != '', msg='Download link is empty!')
        self.assertIn('buildartifact', build_artifact.get_attribute('href'), msg='Is not the build artifact')
        self.save_screenshot(screenshot_type='selenium', append_name='other_artifacts_download')
        os.system('wget %s --no-proxy -P ./dld' %build_artifact.get_attribute('href'))

        output = subprocess.check_output("ls -l ./dld | wc -l", shell=True)
        self.assertTrue(output >= 1, msg='File was not downloaded')
        os.system('rm -rf ./dld')

        ##############
        #  CASE 1397 #
        ##############
    def test_1397(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()

        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)
        self.driver.find_element_by_link_text('core-image-minimal').click()
        time.sleep(1)

        download = self.driver.find_element_by_xpath("html/body/div[4]/div/div/div[2]/div[4]/div/dl/dd[3]/a[2]")
        download.click()
        time.sleep(2)

        self.assertTrue(download.get_attribute('href') != '', msg='Download link is empty!')
        self.assertIn('licensemanifest', download.get_attribute('href'), msg='Is not the license manifest')
        self.save_screenshot(screenshot_type='selenium', append_name='licence_manifes_download')
        os.system('wget %s --no-proxy -P ./dld' %download.get_attribute('href'))

        output = subprocess.check_output("ls -l ./dld | wc -l", shell=True)
        self.assertTrue(output >= 1, msg='File was not downloaded')
        os.system('rm -rf ./dld')


        ##############
        #  CASE 1399 #
        ##############
    def test_1399(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()

        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        img_recipe = 'core-image-minimal'
        software_recipe = 'busybox'
        self.driver.find_element_by_link_text("Image recipes").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys("core-image-efi")
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='add-del-layers']")
        time.sleep(1)
        nr = 0
        for element in elements:
            if element.text == 'Add layer':
                element.click()
                break
            nr += 1

        time.sleep(1)

        try:
            self.driver.find_element_by_id("dependencies-modal")
            time.sleep(1)
            self.driver.find_element_by_xpath(".//*[@id='dependencies-modal-form']/div[3]/button[1]").click()
        except:
            print 'Only one dependency'

        time.sleep(1)
        self.driver.find_element_by_id("change-notification-msg")

        elements = self.driver.find_elements_by_xpath("//td[@class='add-del-layers']")
        time.sleep(1)
        self.assertEqual("Build recipe", elements[nr].text, msg='Add layer button did not become Build recipe.')

        time.sleep(2)

        self.driver.find_element_by_id("topbar-configuration-tab").click()
        time.sleep(1)

        layer = True
        while (layer):
            try:
                delete_button = self.driver.find_element_by_xpath("//*[@id='layers-in-project-list']/li[4]/span")
                delete_button.click()
                self.driver.find_element_by_link_text("Configuration").click()
            except:
                layer = False

        self.driver.find_element_by_link_text("Image recipes").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-imagerecipestable").clear()
        self.driver.find_element_by_id("search-input-imagerecipestable").send_keys(img_recipe)
        self.driver.find_element_by_id("search-submit-imagerecipestable").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        time.sleep(1)
        nr = 1
        for element in elements:
            if element.text == img_recipe:
                break
            nr += 1

        self.driver.find_element_by_xpath(".//*[@id='imagerecipestable']/tbody/tr[%s]/td[9]/button[1]" %nr).click()
        time.sleep(1)

        self.wait_until_build_finish(1, 30)

        # test software recipes

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_link_text("Software recipes").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("3rd-gen-i5-i7-sinit")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='add-del-layers']")
        time.sleep(1)
        nr = 0
        for element in elements:
            if element.text == 'Add layer':
                element.click()
                break
            nr += 1

        time.sleep(1)
        try:
            self.driver.find_element_by_id("dependencies-modal")
            time.sleep(1)
            self.driver.find_element_by_xpath(".//*[@id='dependencies-modal-form']/div[3]/button[1]").click()
        except:
            print 'Only one dependency'

        self.driver.find_element_by_id("change-notification-msg")

        elements = self.driver.find_elements_by_xpath("//td[@class='add-del-layers']")
        time.sleep(1)
        self.assertEqual("Build recipe", elements[nr].text, msg='Add layer button did not become Build recipe.')

        time.sleep(2)

        self.driver.find_element_by_id("topbar-configuration-tab").click()
        time.sleep(1)

        layer = True
        while (layer):
            try:
                delete_button = self.driver.find_element_by_xpath("//*[@id='layers-in-project-list']/li[4]/span")
                delete_button.click()
                self.driver.find_element_by_link_text("Configuration").click()
            except:
                layer = False

        self.driver.find_element_by_link_text("Software recipes").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys(software_recipe)
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        time.sleep(1)
        nr = 1
        for element in elements:
            if element.text == software_recipe:
                break
            nr += 1

        self.driver.find_element_by_xpath(".//*[@id='softwarerecipestable']/tbody/tr[%s]/td[9]/button[1]" %nr).click()
        time.sleep(1)

        self.wait_until_build_finish(1, 30)

        ##############
        #  CASE 1400 #
        ##############
    def test_1400(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()

        self.driver.get(self.base_url)
        machine = "intel-core2-32"

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_link_text("Machines").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-machinestable").clear()
        self.driver.find_element_by_id("search-input-machinestable").send_keys(machine)
        self.driver.find_element_by_id("search-submit-machinestable").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        time.sleep(1)
        nr = 0
        for element in elements:
            if element.text == machine:
                if nr == 0:
                    self.driver.find_element_by_xpath(".//*[@id='machinestable']/tbody/tr/td[6]/button").click()
                else:
                    self.driver.find_element_by_xpath(".//*[@id='machinestable']/tbody/tr[%s]/td[6]/button" % nr).click()
                break
            nr += 1

        time.sleep(1)
        try:
            self.driver.find_element_by_id("dependencies-modal")
            time.sleep(1)
            self.driver.find_element_by_xpath(".//*[@id='dependencies-modal-form']/div[3]/button[1]").click()
        except:
            print 'Only one dependency'

        self.driver.find_element_by_id("change-notification-msg")

        elements = self.driver.find_elements_by_xpath("//td[@class='add-del-layers']")
        time.sleep(1)
        self.assertEqual("Select machine", elements[nr].text, msg='Add layer button did not become select machine.')
        time.sleep(1)

        if nr == 0:
            self.driver.find_element_by_xpath(".//*[@id='machinestable']/tbody/tr/td[6]/a").click()
        else:
            self.driver.find_element_by_xpath(".//*[@id='machinestable']/tbody/tr[%s]/td[6]/a" % nr).click()

        time.sleep(1)

        self.assertEqual(self.driver.find_element_by_id("project-machine-name").text, machine, msg="Machine was not changed")
        time.sleep(1)

        self.driver.find_element_by_xpath("//*[@id='layers-in-project-list']/li[4]/a").click()
        time.sleep(1)

        self.driver.find_element_by_id("targets-tab").click()
        time.sleep(1)

        self.driver.find_element_by_id("search-input-recipestable").click()
        self.driver.find_element_by_id("search-input-recipestable").send_keys("libva")
        self.driver.find_element_by_id("search-submit-recipestable").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        time.sleep(1)
        nr = 1
        for element in elements:
            if element.text == "libva":
                break
            nr += 1

        time.sleep(1)
        self.driver.find_element_by_xpath(".//*[@id='recipestable']/tbody/tr[%s]/td[4]/button" %nr).click()
        time.sleep(2)

        self.wait_until_build_finish(1, 120)

        ##############
        #  CASE 1401 #
        ##############
    def test_1401(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()

        self.driver.get(self.base_url)
        machine1 = "qemux86-64"
        machine2 = "qemumips"

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_id("change-machine-toggle").click()
        time.sleep(1)

        self.driver.find_element_by_id("machine-change-input").clear()
        self.driver.find_element_by_id("machine-change-input").send_keys(machine1)
        self.driver.find_element_by_id("machine-change-btn").click()
        time.sleep(1)

        self.assertEqual(machine1, self.driver.find_element_by_id("project-machine-name").text, msg="Machine was not changed")

        self.driver.find_element_by_id("build-input").clear()
        self.driver.find_element_by_id("build-input").send_keys("core-image-minimal")
        time.sleep(0.5)
        self.driver.find_element_by_id("build-button").click()
        time.sleep(1)

        self.wait_until_build_finish(1, 30)
        self.driver.find_element_by_link_text('core-image-minimal').click()
        time.sleep(1)

        title = self.driver.find_element_by_class_name("page-header").text
        self.assertIn(machine1, title, msg="On build summary page is a different machine")

        self.driver.back()
        time.sleep(1)

        self.driver.find_element_by_id("topbar-configuration-tab").click()
        time.sleep(1)

        self.driver.find_element_by_id("change-machine-toggle").click()
        time.sleep(1)

        self.driver.find_element_by_id("machine-change-input").clear()
        self.driver.find_element_by_id("machine-change-input").send_keys(machine2)
        self.driver.find_element_by_id("machine-change-btn").click()
        time.sleep(1)

        self.assertEqual(machine2, self.driver.find_element_by_id("project-machine-name").text, msg="Machine was not changed")

        self.driver.find_element_by_id("build-input").clear()
        self.driver.find_element_by_id("build-input").send_keys("core-image-sato")
        time.sleep(0.5)
        self.driver.find_element_by_id("build-button").click()
        time.sleep(1)

        self.wait_until_build_finish(1, 30)
        self.driver.find_element_by_link_text('core-image-sato').click()
        time.sleep(1)

        title = self.driver.find_element_by_class_name("page-header").text
        self.assertIn(machine2, title, msg="On build summary page is a different machine")


        ##############
        #  CASE 1402 #
        ##############
    def test_1402(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()

        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_link_text("BitBake variables").click()
        time.sleep(1)

        self.driver.find_element_by_id("change-image_fstypes-icon").click()
        time.sleep(1)

        image_fstypes_list = self.driver.find_element_by_id("all-image_fstypes")
        items = image_fstypes_list.find_elements_by_tag_name("label")
        for item in items:
            if (item.text == 'ext4') | (item.text == 'hddimg'):
                if "checked=\"checked\"" not in item.get_attribute('innerHTML'):
                    item.click()
                    time.sleep(0.5)
                else:
                    print "WARNING: Posible that ext4 and hddimg images to be allready build"

        self.driver.find_element_by_id("apply-change-image_fstypes").click()
        time.sleep(1)

        image_fstypes = self.driver.find_element_by_id("image_fstypes").text
        self.assertIn("ext4", image_fstypes, msg="ext4 is not present in the Image fstypes")
        self.assertIn("hddimg", image_fstypes, msg="hddimg is not present in the Image fstypes")

        self.driver.find_element_by_id("build-input").clear()
        self.driver.find_element_by_id("build-input").send_keys("core-image-minimal")
        self.driver.find_element_by_id("build-button").click()
        time.sleep(1)

        self.driver.find_element_by_partial_link_text("Builds (").click()

        self.wait_until_build_finish(1, 30)


        self.driver.find_element_by_link_text("core-image-minimal").click()
        time.sleep(1)

        self.assertTrue(self.driver.find_element_by_xpath("html/body/div[4]/div/div/div[2]/div[4]/div/dl/dd[4]/ul"),\
                        msg="WARNING: This build did not create any image files - this TC will fail")

        image_files_list = self.driver.find_element_by_xpath("html/body/div[4]/div/div/div[2]/div[4]/div/dl/dd[4]/ul")

        elements = ""
        items = image_files_list.find_elements_by_tag_name("li")
        for item in items:
            elements += item.text
            elements += " "

        self.assertIn("ext4", elements, msg="ext4 is not present in the build Image files")

        other_artifacts_list = self.driver.find_element_by_xpath("html/body/div[4]/div/div/div[2]/div[5]/div/dl/dd/div")
        items = other_artifacts_list.find_elements_by_tag_name("a")
        for item in items:
            elements += item.text
            elements += " "
        self.assertIn("hddimg", elements, msg="hddimg is not present in the build Image files (other artifacts) - Bug 8556")

        ##############
        #  CASE 1403 #
        ##############
    def test_1403(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        default_image_list = ['Software recipe', 'Version', 'Description', 'Layer', 'Build']
        time.sleep(0.5)

        #step 3
        self.driver.find_element_by_link_text("Software recipes").click()
        time.sleep(0.5)

        #step 4
        l = self.get_table_data('softwarerecipestable', 10, 5)
        self.assertTrue(l != [], msg="Image recipes table is not populated")

        head_list = self.get_table_head_text('softwarerecipestable')
        for item in default_image_list:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))

        ##############
        #  CASE 1404 #
        ##############
    def test_1404(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        image_recipes_sortable_dict = {'Software recipe':'name', 'Section':'section', 'Layer':'layer_version__layer__name', 'License':'license'}
        image_recipes_not_sortable_dict = {'Version':'version', 'Description':'get_description_or_summary', 'Recipe file':'recipe-file', \
                                           'Git revision':'layer_version__get_vcs_reference', 'Build':'add-del-layers'}
        time.sleep(0.5)

        #step 2
        self.driver.find_element_by_link_text("Software recipes").click()
        time.sleep(0.5)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        initial_values = [element.text for element in elements]
        time.sleep(1)

        #step 3
        element = self.driver.find_element_by_css_selector('th.name')
        self.assertTrue("i class=\"icon-caret-down\" style=\"display: inline;\"" in element.get_attribute('innerHTML'),\
                        msg='Table not sorted by Image recie')

        #step 4
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-recipe-file").click()
        self.driver.find_element_by_id("checkbox-section").click()
        self.driver.find_element_by_id("checkbox-license").click()
        self.driver.find_element_by_id("checkbox-layer_version__get_vcs_reference").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()

        #step 5
        for column in image_recipes_sortable_dict:
            element = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict[column])
            time.sleep(1)
            if column == 'Software recipe':
                self.assertTrue("a class=\"sorted\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)
            else:
                self.assertTrue("href=\"#\"" in element.get_attribute('innerHTML'), msg='%s column is not sortable' %column)

        for column in image_recipes_not_sortable_dict:
            element = self.driver.find_element_by_css_selector('th.%s' %image_recipes_not_sortable_dict[column])
            time.sleep(1)
            self.assertTrue("<span class=\"muted\">" in element.get_attribute('innerHTML'), msg='%s column is sortable' %column)

        #step 6
        e = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict['Software recipe'])
        e.click()
        time.sleep(1)
        self.assertTrue("<i class=\"icon-caret-up\"" in e.get_attribute('innerHTML'),\
                        msg='Software recipe is not sorted descendent')
        time.sleep(1)

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("meta-intel")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()
        time.sleep(1)

        #step 8
        e = self.driver.find_element_by_css_selector('th.%s' % image_recipes_sortable_dict['Software recipe'])
        self.assertTrue("<i class=\"icon-caret-up\"" in e.get_attribute('innerHTML'),\
                        msg='Software recipe is not sorted descendent after search')

        #continue step 6
        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        values = [element.text for element in elements]

        layers_elements = self.driver.find_elements_by_xpath("//td[@class='layer_version__layer__name']/a")
        layers_elements[0].click()

        time.sleep(1)
        self.driver.back()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        values2 = [element.text for element in elements]
        self.assertEqual(values, values2, "Software Recipe column is not sorted properly")

        #step 7
        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()

        element = self.driver.find_element_by_xpath("//th[@class='section']/a")
        element.click()
        time.sleep(1)
        self.assertTrue("sorted" in element.get_attribute('class'), msg='Table is not sort by Section')
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-section").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)

        elements = self.driver.find_elements_by_xpath("//td[@class='name']")
        values3 = [element.text for element in elements]
        self.assertEqual(initial_values, values3, msg="Default sorting was not restore")

        ##############
        #  CASE 1405 #
        ##############
    def test_1405(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        target_list = ['Software recipe', 'Version', 'Description', 'Recipe file', 'Section', 'Layer', 'License', \
                       'Git revision', 'Build']
        time.sleep(1)

        #step 2
        self.driver.find_element_by_link_text("Software recipes").click()
        time.sleep(1)

        # step 3
        self.assertTrue(self.driver.find_element_by_id("search-input-softwarerecipestable"), "Search input not found")
        self.assertTrue(self.driver.find_element_by_id("search-submit-softwarerecipestable"), " Search button not found")
        all_targets = self.driver.find_element_by_class_name("table-count-softwarerecipestable").text

        # step 4
        self.assertEqual("Search compatible software recipes", \
                         self.driver.find_element_by_id("search-input-softwarerecipestable").get_attribute("placeholder") \
                         ,"Different placeholder text")

        # step 5
        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("c")
        self.assertEqual("c",self.driver.find_element_by_id("search-input-softwarerecipestable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()
        time.sleep(2)

        # step 6
        # returned results
        self.assertEqual("core", self.driver.find_element_by_id("search-input-softwarerecipestable").get_attribute("value"), \
                         msg="Search string is not kept in the text input field")

        targets_after_search = self.driver.find_element_by_class_name("table-count-softwarerecipestable").text
        self.assertNotEqual(all_targets, targets_after_search, msg="Same compatibles targets")

        self.driver.find_element_by_xpath("//*[@id='table-chrome-softwarerecipestable']/div/div[1]/a/i").click()
        time.sleep(2)

        targets_after_clear_search = self.driver.find_element_by_class_name("table-count-softwarerecipestable").text
        self.assertEqual(all_targets, targets_after_clear_search, msg="Different number of compatibles targets")

        #no results
        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("dkasashdsakjdhasjkdashdjk")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()

        time.sleep(3)
        no_targets = self.driver.find_element_by_class_name("table-count-softwarerecipestable").text
        if no_targets=="0":
            self.driver.find_element_by_xpath("//*[@id='no-results-softwarerecipestable']/div/form/button[2]").click()
            time.sleep(2)
            targets_show_all = self.driver.find_element_by_class_name("table-count-softwarerecipestable").text
            self.assertEqual(all_targets, targets_show_all, msg="Different number of compatibles targets")
        else:
            self.fail(msg='Search is not working properly')

        # step 7
        self.driver.find_element_by_id("edit-columns-button").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("checkbox-recipe-file").click()
        self.driver.find_element_by_id("checkbox-section").click()
        self.driver.find_element_by_id("checkbox-license").click()
        self.driver.find_element_by_id("checkbox-layer_version__get_vcs_reference").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("edit-columns-button").click()

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()
        time.sleep(1)

        head_list = self.get_table_head_text('softwarerecipestable')
        for item in target_list:
            self.assertTrue(item in head_list, msg=("%s not found in Directory structure table head" % item))

        # step 8
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        self.driver.find_element_by_id("in_current_project").click()
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()

        time.sleep(2)
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        # bug 8125
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_xpath(".//*[@id='table-chrome-softwarerecipestable']/div/div[1]/a/i").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied after remove search - bug 8125")


        ##############
        #  CASE 1406 #
        ##############
    def test_1406(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_link_text("Software recipes").click()
        time.sleep(1)

        # step 3
        build_element = self.driver.find_element_by_class_name("add-del-layers")
        self.assertIn("<i class=\"icon-filter filtered\"></i>", build_element.get_attribute('innerHTML'), \
                      msg='Build filter dose not exist')

        # step 4
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:not_in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)
        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:all").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        # step 5
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        self.driver.find_element_by_id("in_current_project").click()
        time.sleep(0.5)
        self.driver.find_element_by_id("in_current_project:in_project").click()
        self.driver.find_element_by_xpath("//*[@class='modal-footer']//*[@type='submit']").click()
        time.sleep(2)

        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertIn("btn-primary", filter_class,msg = "Filter is not applied")

        self.driver.find_element_by_id("search-input-softwarerecipestable").clear()
        self.driver.find_element_by_id("search-input-softwarerecipestable").send_keys("core")
        self.driver.find_element_by_id("search-submit-softwarerecipestable").click()

        time.sleep(2)
        filter_class = self.driver.find_element_by_id("in_current_project").get_attribute("class")
        self.assertNotIn("btn-primary", filter_class,msg = "Filter is applied")

        ##############
        #  CASE 1407 #
        ##############
    def test_1407(self):

        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)

        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("selenium-project").click()
        time.sleep(1)

        self.driver.find_element_by_partial_link_text("Builds (").click()
        time.sleep(1)
        self.driver.find_element_by_link_text("core-image-minimal").click()
        time.sleep(1)

        self.driver.find_element_by_xpath(".//*[@id='nav']/ul/li[3]/a").click()
        time.sleep(1)

        elements = self.driver.find_elements_by_xpath("//td[@class='package_name']")
        elements[0].click()
        time.sleep(1)
        self.driver.find_element_by_xpath(".//*[@id='otable']/tbody/tr[1]/td[1]/a").click()
        time.sleep(1)
        self.driver.find_element_by_xpath(".//*[@id='otable']/tbody/tr[1]/td[1]/a").click()
        time.sleep(1)

        self.assertTrue(self.driver.find_element_by_id("dirtable"), msg="Can't find the directory structure table")