3 use Test::More 'tests' => 76;
5 use SGN::Test::WWW::WebDriver;
6 use SGN::Test::Fixture;
8 my $f = SGN::Test::Fixture->new();
9 my $t = SGN::Test::WWW::WebDriver->new();
11 $t->while_logged_in_as("submitter", sub {
14 # test for both excel formats xls and xlsx
15 for my $file ("crosses_plots_upload.xls", "crosses_plots_upload_selenium.xlsx") {
17 $t->get_ok('/breeders/crosses');
20 $t->find_element_ok("upload_crosses_link", "name", "click on upload_crosses_link ")->click();
23 $t->find_element_ok('next_step_intro_button', 'id', 'go to next screen - Intro')->click();
26 # SCREEN 2 /Crossing experiment/
27 # with normal find_by_name method element cannot be find - that is why that strange double xpath structure
28 $t->find_element_ok('//div[@id="manage_page_section_1"]//button[@name="create_crossingtrial_link"]', 'xpath', 'find button to create a new experiment and click');
29 $t->find_element_ok('//div[@id="manage_page_section_1"]//button[@name="create_crossingtrial_link"]', 'xpath', 'find button to create a new experiment and click')->click();
32 # Add New Crossing Experiment Intro/ modal
33 $t->find_element_ok('next_step_add_new_intro', 'id', 'go to next screen in Add New Experiment modal')->click();
35 # Add New Crossing Experiment Information/ modal
36 my $experiment_name = "Selenium_upload_cross_trial_$file";
37 $t->find_element_ok('crossingtrial_name', 'id', 'find "crossing trial name" input and give a name')->send_keys($experiment_name);
39 $t->find_element_ok('crossingtrial_program', 'id', 'find "crossing trial program" select input and click')->click();
41 $t->find_element_ok('//select[@id="crossingtrial_program"]/option[text()="test"]', 'xpath', 'select "test" as value for crossing trial program')->click();
43 $t->find_element_ok('crossingtrial_location', 'id', 'find "crossing trial location" select input and click')->click();
45 $t->find_element_ok('//select[@id="crossingtrial_location"]/option[@value="test_location"]', 'xpath', 'select "test_location" as value for crossing trial location')->click();
47 $t->find_element_ok('crosses_add_project_year_select', 'id', 'find "crossing trial year" select input and click')->click();
49 $t->find_element_ok('//select[@id="crosses_add_project_year_select"]/option[@value="2018"]', 'xpath', 'select "2018" as value for crossing trial year')->click();
51 $t->find_element_ok('crosses_add_project_description', 'id', 'find "crossing trial description" input and give a description')->send_keys("Selenium_upload_cross_trial_description");
53 $t->find_element_ok('create_crossingtrial_submit', 'id', 'find and click "crossing trial submit" input and give a description')->click();
56 # check if added successfully
57 my $trial_submit_info = $t->find_element_ok(
58 '//div[@id="add_crossing_trial_workflow"]//div[contains(@class, "workflow-complete-message")]',
60 'find feedback info after trial submition')->get_attribute('innerHTML');
62 ok($trial_submit_info =~ /Crossing experiment was added successfully/, "Verify feedback after submission, looking for: 'Crossing experiment was added successfully'");
64 $t->find_element_ok('add_crossing_experiment_dismiss_button_2', 'id', 'find and close "Add New Experiment" modal')->click();
67 $t->find_element_ok('next_step_crossing_trial_button', 'id', 'go to next screen - Crossing experiment')->click();
70 # SCREEN 3 /Upload your crosses/
71 $t->find_element_ok('upload_crosses_breeding_program_id', 'id', 'find "crossing trial program" select input and click')->click();
73 $t->find_element_ok('//select[@id="upload_crosses_breeding_program_id"]/option[@title="test"]', 'xpath', 'select "test" as value for crossing experiment')->click();
76 $t->find_element_ok('upload_crosses_crossing_experiment_id', 'id', 'find "crossing trial program" select input and click')->click();
78 $t->find_element_ok("//select[\@id='upload_crosses_crossing_experiment_id']/option[\@title='$experiment_name']", 'xpath', "select '$experiment_name' as value for crossing experiment")->click();
80 $t->find_element_ok('cross_file_format_option', 'id', 'find "file format" select input and click')->click();
82 $t->find_element_ok('//select[@id="cross_file_format_option"]/option[@value="xls_cross_plot"]', 'xpath', 'select "Excel (.xls) file with accession and plot names for parents" as value for crossing file format')->click();
86 my $upload_input = $t->find_element_ok("xls_crosses_plots_file", "id", "find file input");
87 my $filename = $f->config->{basepath} . "/t/data/cross/$file";
88 $t->driver()->upload_file($filename);
89 $upload_input->send_keys($filename);
91 $t->find_element_ok('upload_crosses_submit', 'id', 'find and "submit" uploaded cross file')->click();
94 # Check if added successfully
95 my $cross_submit_info = $t->find_element_ok(
96 '//div[@id="crosses_upload_workflow"]',
98 'find feedback info after trial submition')->get_attribute('innerHTML');
100 ok($cross_submit_info =~ /The crosses file was uploaded successfully/, "Verify feedback after cross submission, looking for: 'The crosses file was uploaded successfully'");
102 $t->find_element_ok('upload_crosses_dismiss_button', 'name', 'find "close" modal button and click')->click();
105 $t->find_element_ok("refresh_crosses_jstree_html_trialtree_button", "id", "find and click 'refresh crosses trial jstree'")->click();
108 $t->find_element_ok('//div[@id="crosses_list"]//i[contains(@class, "jstree-icon")]', 'xpath', 'open a tree with crosses trial list')->click();
111 my $href_to_trial = $t->find_element_ok("//div[\@id='crosses_list']//a[contains(text(), '$experiment_name')]", 'xpath', 'find created cross and take link href')->get_attribute('href');
113 $t->get_ok($href_to_trial);
116 my $cross_table_content = $t->find_element_ok('parent_information', 'id', 'find table with parent information')->get_attribute('innerHTML');
118 ok($cross_table_content =~ /UG120001xUG120002/, "Verify info in the table: UG120001xUG120002");
119 ok($cross_table_content =~ /KASESE_TP2013_842/, "Verify info in the table: KASESE_TP2013_842");
120 ok($cross_table_content =~ /KASESE_TP2013_1591/, "Verify info in the table: KASESE_TP2013_1591");
124 $t->driver()->close();