-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pui.py
934 lines (822 loc) · 47.9 KB
/
test_pui.py
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
from urllib import request
import pytest, os
import csv
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from datetime import datetime
# Assumptions of data in dev will likely be largely always accurate, as dev will be using
# the data subset generated by Alex Duryee in August 2021
_base_url = os.getenv('BASE_URL')
###### TEST SEARCHES ######
def test_main_page_reachable(driver):
driver.get(str(_base_url))
title = driver.title
print(title)
assert title == 'Hollis Archival Collection Guides | HOLLIS for'
def test_search_by_keyword(driver):
# assumes the existance of "Test Resource 123" collection (which is on dev. Better way to do this?)
# repositories/4/resources/11842
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("Test Resource 123")
assert search_field.get_attribute('value') == 'Test Resource 123'
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 1
abstract = results[0].find_element(By.CLASS_NAME, "abstract").text
assert abstract == "Overview:\nTest Resource Abstract"
def test_is_and_the_implied_operator(driver):
# assumes the existance of "Stella Patrick Campbell collection of letters and documents relating to theater" collection
# repositories/24/resources/11720
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("campbell theater")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 9
title = results[0].find_element(By.CLASS_NAME, "record-title")
assert title.get_attribute('href') == _base_url + "repositories/24/resources/11720"
assert title.text == 'Stella Patrick Campbell collection of letters and documents relating to theater'
repo_name = results[0].find_element(By.CLASS_NAME, "repo_name")
assert repo_name.text == "Houghton Library"
assert repo_name.find_element(By.TAG_NAME, 'a').get_attribute('href') == _base_url + "repositories/24"
collection_identifier = results[0].find_element(By.TAG_NAME, "strong")
assert collection_identifier.text == "Collection Identifier: 2003MT-120-2003MT-124, 2003MT-187, 2003MT-238-239"
abstract = results[0].find_element(By.CLASS_NAME, "abstract")
assert abstract.text == "Summary:\nIncludes letters, ephemera, prompt scripts used by Stella Patrick Campbell, known as Mrs. Patrick Campbell, photographs, scrapbook, poster, sketch at age 16 by her sister, manuscript copies of newspaper articles collected by E. Mary Hand, and other documents.\n\n\nScope and Contents\nContains 16 lots purchased from Dominic Winter Book Auction, August 2002."
def test_search_by_creator(driver):
driver.get(str(_base_url))
# search by keyword before searching by creator to distinguish between the two
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("dumbarton oaks")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 25
# then the same search, but with Creator selected from the dropdown
driver.get(str(_base_url))
select = Select(driver.find_element(By.ID, 'field0'))
select.select_by_visible_text("Creator")
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("dumbarton oaks")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 6
def test_search_in_notes(driver):
driver.get(str(_base_url))
# search by keyword before searching by creator to distinguish between the two
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("drugs medicines")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 5
# then the same search, but with Notes selected from the dropdown
driver.get(str(_base_url))
select = Select(driver.find_element(By.ID, 'field0'))
select.select_by_visible_text("Notes")
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("drugs medicines")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 1
def test_search_by_identifier(driver):
driver.get(str(_base_url))
# search by keyword before searching by creator to distinguish between the two
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("MC 381")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 4
# then the same search, but with Notes selected from the dropdown
driver.get(str(_base_url))
select = Select(driver.find_element(By.ID, 'field0'))
select.select_by_visible_text("Identifier")
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("MC 381")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 1
def test_complex_searching(driver):
driver.get(str(_base_url))
# simple search first to contrast
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("watercolor")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 25
# then the complex search
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("watercolor")
plus_button = driver.find_element(By.CLASS_NAME, "btn-default")
plus_button.click()
second_search_field = driver.find_element(By.ID, "q1")
second_search_field.send_keys("caricatures")
second_search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 2
def test_limit_by_record_type(driver):
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
select = Select(driver.find_element(By.ID, 'limit'))
select.select_by_visible_text("Limit collections")
search_field.send_keys("drugs medicines")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 3
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
select = Select(driver.find_element(By.ID, 'limit'))
select.select_by_visible_text("Limit digital materials")
search_field.send_keys("drugs medicines")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 2
def test_limit_by_year(driver):
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("drugs medicines")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 5
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
year_field_1 = driver.find_element(By.ID, "from_year0")
year_field_2 = driver.find_element(By.ID, "to_year0")
year_field_1.send_keys("1876")
year_field_2.send_keys("1877")
search_field.send_keys("drugs medicines")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 2
###### TEST RESULTS ######
def test_results_priority(driver):
# Are collections at the top of the list?
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("watercolor caricatures")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 2
collection_result = results[0]
item_result = results[1]
assert collection_result.find_element(By.TAG_NAME, "i").get_attribute("class") == "fa fa-archive fa-3x"
assert item_result.find_element(By.TAG_NAME, "i").get_attribute("class") == "fa fa-file-o fa-3x"
def test_sort_results_by_title(driver):
# Initial sort by relevance
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
select = Select(driver.find_element(By.ID, 'limit'))
select.select_by_visible_text("Limit collections")
search_field.send_keys("theater")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert results[0].find_element(By.CLASS_NAME, "record-title").text == "Frank Lloyd Wright drawings of Dallas Theater Center"
# Sort by title (asc)
select = Select(driver.find_element(By.ID, 'sort'))
select.select_by_visible_text("Title (ascending)")
sort_button = driver.find_element(By.CLASS_NAME, "sort-button")
sort_button.click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert results[0].find_element(By.CLASS_NAME, "record-title").text == "Amy Daval collection of brochures, pamphlets, and playbills"
# Sort by title (desc)
select = Select(driver.find_element(By.ID, 'sort'))
select.select_by_visible_text("Title (descending)")
sort_button = driver.find_element(By.CLASS_NAME, "sort-button")
sort_button.click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert results[0].find_element(By.CLASS_NAME, "record-title").text == "Zdeněk Seydl costume and stage designs"
def test_sort_results_by_year(driver):
# Initial sort by relevance
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
select = Select(driver.find_element(By.ID, 'limit'))
select.select_by_visible_text("Limit collections")
search_field.send_keys("theater")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert results[0].find_element(By.CLASS_NAME, "record-title").text == "Frank Lloyd Wright drawings of Dallas Theater Center"
# Sort by title (asc)
select = Select(driver.find_element(By.ID, 'sort'))
select.select_by_visible_text("Year (ascending)")
sort_button = driver.find_element(By.CLASS_NAME, "sort-button")
sort_button.click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert results[0].find_element(By.CLASS_NAME, "record-title").text == "Robert Cruikshank drawings for toy theater characters"
# Sort by title (desc)
select = Select(driver.find_element(By.ID, 'sort'))
select.select_by_visible_text("Year (descending)")
sort_button = driver.find_element(By.CLASS_NAME, "sort-button")
sort_button.click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert results[0].find_element(By.CLASS_NAME, "record-title").text == "Harvard Film Archive Visiting Directors Audio Collection"
def test_refine_results_by_repository(driver):
# Initial search
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
select = Select(driver.find_element(By.ID, 'limit'))
select.select_by_visible_text("Limit collections")
search_field.send_keys("theater")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 25
# Filter by loeb music library
filter_zone = driver.find_element(By.CLASS_NAME, "filter_facets")
filter_zone.find_element(By.LINK_TEXT, "Loeb Music Library").click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 6
for result in results:
assert result.find_element(By.CLASS_NAME, "repo_name").text == "Loeb Music Library"
def test_refine_results_by_type(driver):
# Initial search
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
search_field.send_keys("typeface")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 6
filter_zone = driver.find_element(By.CLASS_NAME, "filter_facets")
filter_zone.find_element(By.LINK_TEXT, "Collection").click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 1
def test_refine_results_by_subject(driver):
# Initial search
driver.get(str(_base_url))
search_field = driver.find_element(By.ID, "q0")
select = Select(driver.find_element(By.ID, 'limit'))
select.select_by_visible_text("Limit collections")
search_field.send_keys("theater")
search_field.send_keys(Keys.RETURN)
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 25
filter_zone = driver.find_element(By.CLASS_NAME, "filter_facets")
filter_zone.find_element(By.LINK_TEXT, "Architecture, Modern -- 20th century -- Archival resources").click()
results = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(results) == 6
###### Browse Repositories ######
def test_browse_repositories(driver):
driver.get(str(_base_url) + "repositories")
driver.find_element(By.LINK_TEXT, "Botany Libraries, Orchid Library of Oakes Ames, Harvard University").click()
repo_info = driver.find_elements(By.CLASS_NAME, "repo_info")
assert repo_info[0].text == "Botany Libraries, Orchid Library of Oakes Ames, Harvard University"
assert repo_info[1].text == "http://huh.harvard.edu/libraries"
assert repo_info[2].text == "5 Collections"
assert driver.find_element(By.ID, "lead_graph").text.startswith("The Harvard University Herbaria houses five comprehensive")
contact_info = driver.find_elements(By.CLASS_NAME, "contact")
assert contact_info[0].text.startswith("Harvard University Herbaria")
assert contact_info[1].text.startswith("(617)")
assert contact_info[2].text.startswith("botref")
def test_repository_collections(driver):
driver.get(str(_base_url) + "repositories")
driver.find_element(By.LINK_TEXT, "Botany Libraries, Orchid Library of Oakes Ames, Harvard University").click()
driver.find_element(By.LINK_TEXT, "5 Collections").click()
repo_collections = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(repo_collections) == 5
repo_collections[0].find_element(By.CLASS_NAME, "record-title").click()
assert driver.current_url == _base_url + "repositories/28/resources/10959"
###### Browse Collections ######
def test_browse_collections_and_sort(driver):
driver.get(str(_base_url))
driver.find_element(By.CLASS_NAME, "submenu").click()
driver.find_element(By.LINK_TEXT, "Collections").click()
assert driver.current_url == _base_url + "repositories/resources"
records = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(records) == 25
assert records[0].find_element(By.CLASS_NAME, "record-title").text.startswith("1")
# Sort by title (desc)
select = Select(driver.find_element(By.ID, 'sort'))
select.select_by_visible_text("Title (descending)")
sort_button = driver.find_element(By.CLASS_NAME, "sort-button")
sort_button.click()
records = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(records) == 25
assert records[0].find_element(By.CLASS_NAME, "record-title").text.startswith("Z")
###### Browse Digital Materials ######
def test_browse_digital_materials(driver):
driver.get(str(_base_url))
driver.find_element(By.CLASS_NAME, "submenu").click()
driver.find_element(By.LINK_TEXT, "Digital Materials").click()
assert driver.current_url == _base_url + "objects?limit=digital_object"
records = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(records) == 25
assert records[0].find_element(By.CLASS_NAME, "record-title").text.startswith("(")
# Sort by title (desc)
select = Select(driver.find_element(By.ID, 'sort'))
select.select_by_visible_text("Title (descending)")
sort_button = driver.find_element(By.CLASS_NAME, "sort-button")
sort_button.click()
records = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(records) == 25
assert records[0].find_element(By.CLASS_NAME, "record-title").text.startswith("黃")
###### Test Finding Aid ######
def test_open_finding_aid(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
assert driver.find_element(By.CLASS_NAME, "full-chars").text == "Albert F. Blakeslee correspondence and notebooks"
def test_collection_organization(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
sleep(1)
sidebar = driver.find_element(By.ID, "sidebar")
assert sidebar.find_element(By.CLASS_NAME, "title").text == "Albert F. Blakeslee correspondence and notebooks"
nodes = sidebar.find_elements(By.CLASS_NAME, "largetree-node")
assert len(nodes) == 2
# 'Correspondence' and 'Notebooks' appear more than once due to screen-reader only accessibility text added
# in some version between 3.0.2 and 3.3.1
assert nodes[0].text == "Correspondence\nCorrespondence, 1923-1960"
assert nodes[1].text == "Notebooks\nNotebooks, 1912-1941"
# expand an item
nodes[0].find_element(By.CLASS_NAME, "expandme").click()
before_expand_titles = sidebar.find_elements(By.CLASS_NAME, "record-title")
assert len(before_expand_titles) == 3
sleep(1)
expanded_titles = sidebar.find_elements(By.CLASS_NAME, "record-title")
assert len(expanded_titles) == 10
assert expanded_titles[2].text == "Correspondence between Blakeslee and Oscar Hagen, 1936"
assert expanded_titles[8].text == "Correspondence between Sophia Satina and Alfred Lender, 1932-1936"
# test navigation to a component
expanded_titles[2].click()
assert driver.current_url == _base_url + "repositories/20/archival_objects/262128"
assert driver.find_element(By.CLASS_NAME, "full-chars").text == "Correspondence between Blakeslee and Oscar Hagen, 1936"
def test_collection_overview_tab(driver):
# navigate to collection_organization so we can also test the collection overview link, which is the default when visiting the resource
driver.get(str(_base_url) + "repositories/20/resources/1182/collection_organization")
driver.find_element(By.LINK_TEXT, "COLLECTION OVERVIEW").click()
assert driver.current_url == str(_base_url) + "repositories/20/resources/1182"
sleep(1) # main panel can take a moment to load
# check collection overview element counts and contents
main_panel = driver.find_element(By.CLASS_NAME, "col-sm-9")
# upper half
upper_details = main_panel.find_element(By.CLASS_NAME, "upper-record-details")
divs = upper_details.find_elements(By.TAG_NAME, "div")
assert len(divs) == 4
assert divs[0].find_element(By.TAG_NAME, "h4").text == "Scope and Content"
assert divs[0].find_element(By.CLASS_NAME, "note-content").text.startswith("This collection consists of correspondence between Blakeslee and other botanists")
assert divs[2].find_element(By.TAG_NAME, "h4").text == "Conditions Governing Access"
assert divs[2].find_element(By.CLASS_NAME, "note-content").text.startswith("The collection is available by appointment for research. Researchers")
h4s = upper_details.find_elements(By.TAG_NAME, "h4")
assert len(h4s) == 4
assert h4s[1].text == "Dates"
assert h4s[3].text == "Extent"
assert upper_details.find_element(By.CLASS_NAME, "dates").text == "1912-1960"
h3s = upper_details.find_elements(By.TAG_NAME, "h3")
assert len(h3s) == 1
assert h3s[0].text == "Creator"
uls = upper_details.find_elements(By.TAG_NAME, "ul")
assert len(uls) == 2
creator_list_items = uls[1].find_elements(By.TAG_NAME, "li")
assert len(creator_list_items) == 1
assert creator_list_items[0].text == "Blakeslee, Albert Francis, 1874-1954 (Person)"
assert creator_list_items[0].find_element(By.TAG_NAME, "a").text == "Blakeslee, Albert Francis, 1874-1954"
assert upper_details.find_element(By.CLASS_NAME, "extent").text == "1 collection (1 box)"
# lower half
lower_details = main_panel.find_element(By.CLASS_NAME, "acc_holder")
panel_titles = lower_details.find_elements(By.CLASS_NAME, "panel-title")
assert len(panel_titles) == 4
assert panel_titles[0].text == "ADDITIONAL DESCRIPTION"
assert panel_titles[1].text == "RELATED NAMES"
assert panel_titles[2].text == "ADMINISTRATIVE INFORMATION"
assert panel_titles[3].text == "REPOSITORY DETAILS"
panel_bodies = lower_details.find_elements(By.CLASS_NAME, "panel-body")
assert len(panel_bodies) == 4
panel_one_notes = panel_bodies[0].find_elements(By.CLASS_NAME, "note")
assert len(panel_one_notes) == 4
assert panel_one_notes[0].find_element(By.TAG_NAME, "h4").text == "Biography"
assert panel_one_notes[0].find_elements(By.CLASS_NAME, "note-content")[0].text.startswith("Albert Francis Blakeslee was born")
assert panel_one_notes[0].find_elements(By.CLASS_NAME, "note-content")[1].text.startswith("Source")
assert panel_bodies[1].find_element(By.TAG_NAME, "h3").text == "Creator"
lis = panel_bodies[1].find_elements(By.TAG_NAME, "li")
assert len(lis) == 1
assert lis[0].text == "Blakeslee, Albert Francis, 1874-1954 (Person)"
assert lis[0].find_element(By.TAG_NAME, "a").text == "Blakeslee, Albert Francis, 1874-1954"
dts = panel_bodies[2].find_elements(By.TAG_NAME, "dt")
assert len(dts) == 6
assert dts[0].text == "Title"
assert dts[1].text == "Status"
assert dts[2].text == "Author"
assert dts[3].text == "Description rules"
assert dts[4].text == "Language of description"
assert dts[5].text == "EAD ID"
dds = panel_bodies[2].find_elements(By.TAG_NAME, "dd")
assert dds[0].text.startswith("Blakeslee, Albert Francis, 1874-1954")
assert dds[1].text == "completed"
assert dds[2].text == "Botany Libraries, Farlow Reference Library of Cryptogamic Botany, Harvard University."
assert dds[3].text == "dacs"
assert dds[4].text == "und"
assert dds[5].text == "far00002"
assert panel_bodies[3].find_element(By.TAG_NAME, "h3").text == "Repository Details"
assert panel_bodies[3].find_element(By.XPATH, "//h3/following-sibling::p").text == "Part of the Botany Libraries, Farlow Reference Library of Cryptogamic Botany, Harvard University Repository"
assert panel_bodies[3].find_element(By.CLASS_NAME, "website").find_element(By.TAG_NAME, "a").text == "http://huh.harvard.edu/libraries"
assert panel_bodies[3].find_element(By.ID, "lead_graph").text.startswith("The Harvard University Herbaria houses five research libraries that are managed")
contact_info = panel_bodies[3].find_element(By.CLASS_NAME, "contact_info")
assert contact_info.find_element(By.TAG_NAME, "strong").text == "Contact:"
spans = contact_info.find_elements(By.TAG_NAME, "span")
assert len(spans) == 7
assert spans[0].text.startswith("Harvard University Herbaria")
assert spans[1].text.startswith("C")
assert spans[2].text.startswith("M")
assert spans[3].text.startswith("0")
assert spans[4].text.startswith("U")
assert spans[5].text.startswith("(617)")
assert spans[6].text.startswith("bot")
# also check total counts in both sections in order to see if there are extras
assert len(upper_details.find_elements(By.XPATH, ".//*")) == 20
assert len(lower_details.find_elements(By.XPATH, ".//*")) == 105
def test_collection_inventory(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
driver.find_element(By.LINK_TEXT, "COLLECTION INVENTORY").click()
assert driver.current_url == _base_url + "repositories/20/resources/1182/collection_organization"
sleep(1)
main_panel = driver.find_element(By.CLASS_NAME, "col-sm-9")
# spot check some records on different levels of hierarchy
infinite_records = main_panel.find_elements(By.CLASS_NAME, "infinite-record-record")
assert infinite_records[0].find_element(By.CLASS_NAME, "record-title").text == "Albert F. Blakeslee correspondence and notebooks"
assert infinite_records[0].find_element(By.CLASS_NAME, "information").find_element(By.CLASS_NAME, "record-type-badge").text == " Collection"
assert infinite_records[0].find_element(By.CLASS_NAME, "information").find_element(By.CLASS_NAME, "identifier").text == "Identifier:\n far00002"
assert infinite_records[0].find_element(By.CLASS_NAME, "note-content").text.startswith("This collection consists of correspondence between Blakeslee and other")
dts = infinite_records[0].find_elements(By.TAG_NAME, "dt")
assert dts[0].text == "Conditions Governing Access"
assert dts[1].text == "Dates"
assert dts[2].text == "Extent"
assert dts[3].text == "Related Names"
assert dts[4].text == "Language of Materials"
dds = infinite_records[0].find_elements(By.TAG_NAME, "dd")
assert dds[0].text.startswith("The collection is available by appointment for research")
assert dds[1].text == "1912-1960"
assert dds[2].text == "1 collection (1 box)"
assert dds[3].text == "Blakeslee, Albert Francis, 1874-1954"
assert dds[4].text == "English"
assert len(infinite_records[0].find_elements(By.XPATH, ".//*")) == 31
assert infinite_records[1].find_element(By.CLASS_NAME, "record-title").text == "Correspondence, 1923-1960"
assert infinite_records[1].find_element(By.CLASS_NAME, "record-type-badge").text == " Series"
assert infinite_records[1].find_element(By.CLASS_NAME, "identifier").text == "Identifier:\n I"
assert infinite_records[1].find_element(By.TAG_NAME, "dt").text == "Dates"
assert infinite_records[1].find_element(By.TAG_NAME, "dd").text == "1923-1960"
assert len(infinite_records[1].find_elements(By.XPATH, ".//*")) == 16
assert infinite_records[2].find_element(By.CLASS_NAME, "record-title").text == "Correspondence between Blakeslee and Oscar Hagen, 1936"
assert infinite_records[2].find_element(By.CLASS_NAME, "archival_object").text == " File — Box: 1, Folder: 1"
assert infinite_records[2].find_element(By.TAG_NAME, "dt").text == "Dates"
assert infinite_records[2].find_element(By.TAG_NAME, "dd").text == "1936"
assert len(infinite_records[2].find_elements(By.XPATH, ".//*")) == 13
# Check that items in the collection inventory match those in the sidebar
# This also verifies that the infinite scroll is working properly
expandme_icons = driver.find_element(By.ID, "sidebar").find_elements(By.CLASS_NAME, "expandme-icon")
for icon in expandme_icons:
icon.click()
sleep(2)
sidebar_records = driver.find_element(By.ID, "sidebar").find_elements(By.CLASS_NAME, "record-title")
assert len(infinite_records) == len(sidebar_records) == 19
index = 0
actions = ActionChains(driver)
for record in infinite_records:
# we need to scroll so the infinite-record loads records properly
actions.move_to_element(record).perform()
assert record.find_element(By.CLASS_NAME, "record-title").text == sidebar_records[index].text
index += 1
driver.find_element(By.LINK_TEXT, "Bibliography on mucors, undated").click()
assert driver.current_url == str(_base_url) + "repositories/20/archival_objects/262143"
def test_digital_materials_tab(driver):
# Navigate to a resource with digital materials
driver.get(str(_base_url) + "repositories/15/resources/10122")
assert driver.find_element(By.CLASS_NAME, "full-chars").text == "Peter S. Ashton Sarawak fieldwork papers"
digital_meterials_nav_button = driver.find_elements(By.CLASS_NAME, "nav-pill")[2]
assert digital_meterials_nav_button.text == "DIGITAL MATERIAL (504)"
digital_meterials_nav_button.find_element(By.TAG_NAME, "a").click()
assert driver.current_url == str(_base_url) + "repositories/15/resources/10122/digital_only"
records = driver.find_elements(By.CLASS_NAME, "recordrow")
assert len(records) == 25
pagination = driver.find_element(By.CLASS_NAME, "pagination").find_elements(By.TAG_NAME, "li")
assert pagination[-1].text == "→Next"
assert pagination[-2].text == "21"
# Spot check a few records
assert records[0].find_element(By.CLASS_NAME, "record-title").text == "Locality: Temiai/Temalad divide, Hose Mountains"
assert records[0].find_element(By.CLASS_NAME, "result_context").text.startswith("FOUND IN")
assert records[0].find_element(By.CLASS_NAME, "repo_name").text == "Botany Libraries, Arnold Arboretum Library (Cambridge), Harvard University"
ancestors = records[0].find_elements(By.CLASS_NAME, "ancestor")
assert ancestors[0].text == "Collection: Peter S. Ashton Sarawak fieldwork papers"
assert ancestors[1].text == "Series: Plots"
assert ancestors[2].text == "Sub-Series: Plot contour maps"
assert ancestors[3].text == "File: Plots A 1 - F 4"
assert records[0].find_element(By.CLASS_NAME, "inline-label").text == "Scope and Contents"
assert records[0].find_element(By.TAG_NAME, "p").text == "Altitude: 2850'. Dacite substrate."
assert records[1].find_element(By.CLASS_NAME, "record-title").text == "Locality: Ulu Pila, Carapa Pila"
assert records[1].find_element(By.CLASS_NAME, "result_context").text.startswith("FOUND IN")
assert records[1].find_element(By.CLASS_NAME, "repo_name").text == "Botany Libraries, Arnold Arboretum Library (Cambridge), Harvard University"
ancestors = records[1].find_elements(By.CLASS_NAME, "ancestor")
assert ancestors[0].text == "Collection: Peter S. Ashton Sarawak fieldwork papers"
assert ancestors[1].text == "Series: Plots"
assert ancestors[2].text == "Sub-Series: Plot contour maps"
assert ancestors[3].text == "File: Plots A 1 - F 4"
assert records[1].find_element(By.CLASS_NAME, "inline-label").text == "Scope and Contents"
assert records[1].find_element(By.TAG_NAME, "p").text == "Altitude: 2750'. Basalt substrate."
# Test link
ancestors[1].find_element(By.TAG_NAME, "a").click()
assert driver.current_url == str(_base_url) + "repositories/15/archival_objects/3197502"
def test_search_within_collection(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
collection_name = driver.find_element(By.CLASS_NAME, "full-chars").text
search_field = driver.find_element(By.ID, "filter_q0")
search_field.send_keys("Nutrient")
assert search_field.get_attribute('value') == 'Nutrient'
search_field.send_keys(Keys.RETURN)
records = driver.find_elements(By.CLASS_NAME, "recordrow")
# ensure that all results are from the collection that was searched-within
assert len(records) == 2
for record in records:
assert record.find_elements(By.TAG_NAME, "span")[1].text == "Collection: " + collection_name
##### TEST FULL FINDING AID MENU OPTIONS ######
def test_finding_aid_citation(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
# Citation button has the request class for some reason
driver.find_element(By.CLASS_NAME, "request").click()
sleep(1)
description_tab = driver.find_element(By.ID, "item_description_citation")
today = datetime.now().strftime("%B %-d, %Y")
assert description_tab.text == f"Albert F. Blakeslee correspondence and notebooks, 1912-1960. far00002. Archives of the Farlow Herbarium of Cryptogamic Botany, Harvard University. https://id.lib.harvard.edu/ead/far00002/catalog Accessed {today}."
assert driver.find_element(By.ID, "item_citation").text == "Albert F. Blakeslee correspondence and notebooks, 1912-1960. far00002. Archives of the Farlow Herbarium of Cryptogamic Botany, Harvard University."
def test_download_pdf(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
driver.find_element(By.ID, "print_button").click()
sleep(3)
file_path = "/home/puitester/far00002.pdf"
assert os.path.isfile(file_path)
# TODO: PARSE PDF AND TEST FOR CONTENTS
def test_finding_aid_request_button(driver):
# Only applies to repositories where the 'request list' plugin is not enabled
driver.get(str(_base_url) + "repositories/6/archival_objects/1377844")
driver.find_element(By.CLASS_NAME, "request").click()
sleep(1)
# Tag text is empty when looked at in Selenium, despite being in the page source and working properly on the page itself.
# In lieu of comparing text, we check that the request popup is open and contains the correct tags
request_popups = driver.find_elements(By.ID, "request_popup")
assert len(request_popups) == 1
assert len(request_popups[0].find_elements(By.TAG_NAME, "strong")) == 1
assert len(request_popups[0].find_elements(By.TAG_NAME, "p")) == 1
def test_download_csv(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
driver.find_element(By.CLASS_NAME, "csv").click()
sleep(3)
file_path = "/home/puitester/collection_1182.csv"
assert os.path.isfile(file_path)
file = open(file_path)
reader = csv.reader(file)
downloaded_rows = []
for row in reader:
downloaded_rows.append(row)
file = open("/home/puitester/test_data/test_data.csv")
reader = csv.reader(file)
test_rows = []
for row in reader:
test_rows.append(row)
index = 0
for row in downloaded_rows:
print(index)
assert row == test_rows[index]
index += 1
def test_finding_aid_component_citation(driver):
driver.get(str(_base_url) + "repositories/20/resources/1182")
# Look at the top level resource to ensure citations are not identical
driver.find_element(By.CLASS_NAME, "request").click()
sleep(1)
description_tab = driver.find_element(By.ID, "item_description_citation")
today = datetime.now().strftime("%B %-d, %Y")
top_level_text = f"Albert F. Blakeslee correspondence and notebooks, 1912-1960. far00002. Archives of the Farlow Herbarium of Cryptogamic Botany, Harvard University. https://id.lib.harvard.edu/ead/far00002/catalog Accessed {today}."
assert description_tab.text == top_level_text
driver.get(str(_base_url) + "repositories/20/resources/1182")
sleep(1)
driver.find_element(By.ID, "sidebar").find_element(By.LINK_TEXT, "Correspondence, 1923-1960").click()
assert driver.current_url == "https://aspacepui-dev.lib.harvard.edu/repositories/20/archival_objects/262126"
driver.find_element(By.CLASS_NAME, "request").click()
sleep(1)
description_tab = driver.find_element(By.ID, "item_description_citation")
today = datetime.now().strftime("%B %-d, %Y")
assert description_tab.text == f"Correspondence, 1923-1960. Albert F. Blakeslee correspondence and notebooks, far00002, I. Botany Libraries, Farlow Reference Library of Cryptogamic Botany, Harvard University. https://id.lib.harvard.edu/ead/c/far00002c00001/catalog Accessed {today}."
assert driver.find_element(By.ID, "item_citation").text == "Correspondence, 1923-1960. Albert F. Blakeslee correspondence and notebooks, far00002, I. Botany Libraries, Farlow Reference Library of Cryptogamic Botany, Harvard University."
def test_add_to_request_list_button_present(driver):
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
add_to_request_list_button = driver.find_elements(By.CLASS_NAME, "request_list_action_button")
assert len(add_to_request_list_button) == 1
def test_add_to_request_list_button_not_present(driver):
# For repos where the request list plugin is not enabled
driver.get(str(_base_url) + "repositories/6/archival_objects/1377844")
add_to_request_list_button = driver.find_elements(By.CLASS_NAME, "request_list_action_button")
assert len(add_to_request_list_button) == 0
##### TEST AEON REQUESTS ######
def test_add_to_request_list_button_press(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (0)"
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (1)"
def test_add_two_items_to_request_list(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (0)"
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (1)"
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (1)"
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (2)"
def test_add_three_items_to_request_list(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (0)"
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (1)"
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (1)"
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (2)"
driver.get(str(_base_url) + "repositories/8/archival_objects/2405272")
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (2)"
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
assert driver.find_element(By.ID, "request_list_top_menu").text == "REQUEST (3)"
def test_are_items_on_request_list(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/8/archival_objects/2405272")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.find_element(By.ID, "request_list_top_menu").click()
sleep(1)
# For some reason, the request list menu item is occasionally determined as non-interactable by Selenium, so if that's the
# case, we visit the request list page directly. This behavior has never been observed outside of Selenium-testing contexts
try:
driver.find_element(By.CLASS_NAME, "dropdown-menu-right").find_elements(By.TAG_NAME, "a")[0].click()
except:
driver.get(str(_base_url) + "plugin/request_list/harvard")
assert driver.current_url == str(_base_url) + "plugin/request_list/harvard"
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
assert len(request_list_items) == 3
# Assert all three items display the correct information
assert request_list_items[0].find_element(By.CLASS_NAME, "rl-display-left").text == "1"
assert len(request_list_items[0].find_elements(By.XPATH, ".//*")) == 56
item_rows = request_list_items[0].find_elements(By.TAG_NAME, "td")
assert item_rows[2].text == "Item: Correspondence, 1923-1960"
assert item_rows[3].text == "Found In: Albert F. Blakeslee correspondence and notebooks"
assert item_rows[4].text == "Collection Call Number: far00002 , Item Call Number: I"
assert item_rows[5].text == ""
assert item_rows[6].text == "Repository: Botany Libraries, Farlow Reference Library of Cryptogamic Botany, Harvard University"
assert item_rows[7].text == "Restrictions: The collection is available by appointment for research. Researchers must register and provide valid photo identification. Please contact [email protected] for additional information."
assert request_list_items[1].find_element(By.CLASS_NAME, "rl-display-left").text == "2"
assert len(request_list_items[1].find_elements(By.XPATH, ".//*")) == 53
item_rows = request_list_items[1].find_elements(By.TAG_NAME, "td")
assert item_rows[2].text == "Item: Type case, 2012-2015"
assert item_rows[3].text == "Found In: 83M80: Letterpress in the digital era: records"
assert item_rows[4].text == "Collection Call Number: MS Typ 1287"
assert item_rows[5].text == ""
assert item_rows[6].text == "Repository: Houghton Library"
assert item_rows[7].text == "Restrictions: Open for research.; A portion of this collection is shelved offsite at the Harvard Depository. Retrieval requires advance notice. Readers should check with Houghton Public Services staff to determine what material is offsite and retrieval policies and times."
assert request_list_items[2].find_element(By.CLASS_NAME, "rl-display-left").text == "3"
assert len(request_list_items[2].find_elements(By.XPATH, ".//*")) == 53
item_rows = request_list_items[2].find_elements(By.TAG_NAME, "td")
assert item_rows[2].text == "Item: Series I. PERSONAL PAPERS, 1933-1984 (#1-246, 547, 2136-2137, Mem.1, Mem.2), 1933-1985"
assert item_rows[3].text == "Found In: Papers of Betty Friedan, 1933-1985"
assert item_rows[4].text == "Collection Call Number: MC 575; T-97; T-125, Vt-1; Phon-7"
assert item_rows[5].text == ""
assert item_rows[6].text == "Repository: Schlesinger Library, Radcliffe Institute"
assert item_rows[7].text.startswith("Restrictions: Access. During the lifetimes of the Friedan children (Daniel, Emily, and Jonathan), all readers must sign a special permission form. Some folders in Series III (#415-425, 427-429, 431-434")
def test_reading_room_request(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/8/archival_objects/2405272")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.find_element(By.ID, "request_list_top_menu").click()
sleep(1)
# For some reason, the request list menu item is occasionally determined as non-interactable by Selenium, so if that's the
# case, we visit the request list page directly. This behavior has never been observed outside of Selenium-testing contexts
try:
driver.find_element(By.CLASS_NAME, "dropdown-menu-right").find_elements(By.TAG_NAME, "a")[0].click()
except:
driver.get(str(_base_url) + "plugin/request_list/harvard")
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
request_list_items[1].find_element(By.TAG_NAME, "input").click()
request_list_items[2].find_element(By.TAG_NAME, "input").click()
driver.find_element(By.CLASS_NAME, "glyphicon-calendar").click()
sleep(1)
dates = driver.find_element(By.CLASS_NAME, "datepicker-days").find_elements(By.TAG_NAME, "td")
for day in dates:
if day.get_attribute("class") == "day":
day.click()
break
sleep(1)
driver.find_element(By.CLASS_NAME, "submit-requests").click()
sleep(1)
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
# Check that there are two remaining items, and that the correct item was removed from the list
assert len(request_list_items) == 2
assert request_list_items[0].find_element(By.CLASS_NAME, "rl-display-left").text == "1"
assert request_list_items[0].find_elements(By.TAG_NAME, "td")[2].text == "Item: Type case, 2012-2015"
assert request_list_items[1].find_element(By.CLASS_NAME, "rl-display-left").text == "2"
assert request_list_items[1].find_elements(By.TAG_NAME, "td")[2].text == "Item: Series I. PERSONAL PAPERS, 1933-1984 (#1-246, 547, 2136-2137, Mem.1, Mem.2), 1933-1985"
def test_copy_request(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/8/archival_objects/2405272")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.find_element(By.ID, "request_list_top_menu").click()
sleep(1)
# For some reason, the request list menu item is occasionally determined as non-interactable by Selenium, so if that's the
# case, we visit the request list page directly. This behavior has never been observed outside of Selenium-testing contexts
try:
driver.find_element(By.CLASS_NAME, "dropdown-menu-right").find_elements(By.TAG_NAME, "a")[0].click()
except:
driver.get(str(_base_url) + "plugin/request_list/harvard")
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
request_list_items[0].find_element(By.TAG_NAME, "input").click()
request_list_items[2].find_element(By.TAG_NAME, "input").click()
all_selects = driver.find_elements(By.TAG_NAME, "select")
select = Select(all_selects[0])
select.select_by_visible_text("Copy")
select = Select(all_selects[1])
select.select_by_visible_text("Print")
select = Select(all_selects[2])
select.select_by_visible_text("Campus Pickup")
driver.find_element(By.CLASS_NAME, "submit-requests").click()
sleep(1)
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
# Check that there are two remaining items, and that the correct item was removed from the list
assert len(request_list_items) == 2
assert request_list_items[0].find_element(By.CLASS_NAME, "rl-display-left").text == "1"
assert request_list_items[0].find_elements(By.TAG_NAME, "td")[2].text == "Item: Correspondence, 1923-1960"
assert request_list_items[1].find_element(By.CLASS_NAME, "rl-display-left").text == "2"
assert request_list_items[1].find_elements(By.TAG_NAME, "td")[2].text == "Item: Series I. PERSONAL PAPERS, 1933-1984 (#1-246, 547, 2136-2137, Mem.1, Mem.2), 1933-1985"
def test_copy_request(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/8/archival_objects/2405272")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.find_element(By.ID, "request_list_top_menu").click()
sleep(1)
# For some reason, the request list menu item is occasionally determined as non-interactable by Selenium, so if that's the
# case, we visit the request list page directly. This behavior has never been observed outside of Selenium-testing contexts
try:
driver.find_element(By.CLASS_NAME, "dropdown-menu-right").find_elements(By.TAG_NAME, "a")[0].click()
except:
driver.get(str(_base_url) + "plugin/request_list/harvard")
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
request_list_items[0].find_element(By.TAG_NAME, "input").click()
request_list_items[1].find_element(By.TAG_NAME, "input").click()
select = Select(driver.find_element(By.ID, "request_type_select"))
select.select_by_visible_text("Save for Later")
driver.find_element(By.CLASS_NAME, "submit-requests").click()
sleep(1)
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
# Check that there are two remaining items, and that the correct item was removed from the list
assert len(request_list_items) == 2
assert request_list_items[0].find_element(By.CLASS_NAME, "rl-display-left").text == "1"
assert request_list_items[0].find_elements(By.TAG_NAME, "td")[2].text == "Item: Correspondence, 1923-1960"
assert request_list_items[1].find_element(By.CLASS_NAME, "rl-display-left").text == "2"
assert request_list_items[1].find_elements(By.TAG_NAME, "td")[2].text == "Item: Type case, 2012-2015"
def test_submit_multiple_requests_at_once(driver):
driver.delete_cookie("as_pui_request_list_list_contents")
driver.get(str(_base_url) + "repositories/20/archival_objects/262126")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/24/archival_objects/3129739")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.get(str(_base_url) + "repositories/8/archival_objects/2405272")
driver.find_element(By.CLASS_NAME, "request_list_action_button").click()
driver.find_element(By.ID, "request_list_top_menu").click()
sleep(1)
# For some reason, the request list menu item is occasionally determined as non-interactable by Selenium, so if that's the
# case, we visit the request list page directly. This behavior has never been observed outside of Selenium-testing contexts
try:
driver.find_element(By.CLASS_NAME, "dropdown-menu-right").find_elements(By.TAG_NAME, "a")[0].click()
except:
driver.get(str(_base_url) + "plugin/request_list/harvard")
select = Select(driver.find_element(By.ID, "request_type_select"))
select.select_by_visible_text("Save for Later")
driver.find_element(By.CLASS_NAME, "submit-requests").click()
sleep(1)
request_list_items = driver.find_elements(By.CLASS_NAME, "rl-list-item")
# Check that there are two remaining items, and that the correct item was removed from the list
assert len(request_list_items) == 0
@pytest.fixture(scope='session', autouse=True)
def driver():
# Will be executed before the first test
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--window-size=1920,1080')
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(options=options)
driver.maximize_window()
yield driver
# Will be executed after the last test
driver.quit()