diff --git a/t/selenium2/breeders/01_create_trial.t b/t/selenium2/breeders/01_create_trial.t index 0a9ccc954d..64583e62a8 100644 --- a/t/selenium2/breeders/01_create_trial.t +++ b/t/selenium2/breeders/01_create_trial.t @@ -3,52 +3,130 @@ use strict; use lib 't/lib'; -use Test::More; +use Test::More "tests" => 51; use SGN::Test::WWW::WebDriver; my $t = SGN::Test::WWW::WebDriver->new(); $t->while_logged_in_as( - "submitter", - - - sub { - $t->get_ok('/breeders/trials'); - my $refresh_tree = $t->find_element_ok("refresh_jstree_html", "name", "refresh tree")->click(); - sleep(3); - my $add_project_link = $t->find_element_ok('add_project_link', 'id', "find add trial link"); - - $add_project_link->click(); - - sleep(1); - - $t->find_element_ok('new_trial_name', 'id', "find new trial name input box")->send_keys("Test trial 1"); - - $t->find_element_ok('add_project_year', 'id', "find trial year input box")->send_keys("2015"); - - $t->find_element_ok('add_project_location', 'id', "find project location input box")->send_keys("test_location"); - - $t->find_element_ok('add_project_description', 'id', "find project description input box")->send_keys("test test test"); - - $t->find_element_ok('select_design_method', 'id', "find field layout design method")->click('Completely Randomized'); - - $t->find_element_ok('select_list_list_select', 'id', "find list select select box")->click('test_stocks'); - - $t->find_element_ok('rep_count', 'id', "find replicate count input box")->send_keys("3"); - - $t->find_element_ok('new_trial_submit', 'id', "find Add button")->click(); - sleep(15); - - $t->find_element_ok('new_trial_confirm_submit', 'id', "find trial design confirm button")->click(); - - sleep(10); - - $t->find_element_ok('trial_saved_dialog_message_ok_button', 'id', "find trial saved dialog")->click(); - - sleep(1); - - }); - - -done_testing(); + "submitter", + + + sub { + $t->get_ok('/breeders/trials'); + sleep(2); + $t->find_element_ok("refresh_jstree_html", "name", "refresh tree")->click(); + sleep(3); + my $add_project_link = $t->find_element_ok('add_project_link', 'id', "find add trial link"); + + $add_project_link->click(); + + sleep(1); + + # SCREEN 1 /Intro/ + $t->find_element_ok('//div[@class="panel-body"]//ol//li//center//button[text()="Go to Next Step"]', + 'xpath', 'go to next screen - Intro')->click(); + # SCREEN 2 /Trial information/ + $t->find_element_ok('select_breeding_program', 'id', 'find breeding program select and click "test"') + ->send_keys("test"); + + $t->find_element_ok('add_project_location', 'id', "find trial location select input")->click(); + + my $trail_name = sprintf("Trial_selenium_%d", int(rand(1000))); + $t->find_element_ok('new_trial_name', 'id', "find new trial name input box")->send_keys($trail_name); + $t->find_element_ok('add_project_type', 'id', "find project type select list")->send_keys("misc_trial"); + $t->find_element_ok('option[title="misc_trial"]', "css", "find trial type misc_trial from select")->click(); + $t->find_element_ok('add_project_year', 'id', "find trial year select list")->send_keys("2015"); + $t->find_element_ok('option[value="2015"]', "css", "find trial year 2015 from select")->click(); + $t->find_element_ok('add_project_plot_width', 'id', "find trial plot width input")->send_keys("10"); + $t->find_element_ok('add_project_plot_length', 'id', "find trial plot length input")->send_keys("10"); + $t->find_element_ok('new_trial_field_size', 'id', "find trial field size input")->send_keys("5"); + $t->find_element_ok('add_plant_entries', 'id', "find trial plants per plot input")->send_keys("10"); + $t->find_element_ok('add_project_description', 'id', "find project description input box") + ->send_keys("Test trial selenium 1 description field test"); + + $t->find_element_ok('select_stock_type', 'id', "find trial stock type select input"); + $t->find_element_ok('option[value="accession"]', "css", "find accession value for stock type")->click(); + $t->find_element_ok('select_design_method', 'id', "find field trial description input")->click(); + $t->find_element_ok('option[value="CRD"]', "css", "find accession value for stock type")->click(); + $t->find_element_ok('create_trial_validate_form_button', 'id', "find form validation button and click")->click(); + sleep(3); + + $t->find_element_ok('button[name="create_trial_submit"]', 'css', "find form submit button and click")->click(); + sleep(3); + + # SCREEN 3 /Design Information/ + $t->find_element_ok('rep_count', 'id', "find trial replicates count input")->send_keys("1"); + sleep(1); + $t->find_element_ok('show_list_of_accession_section', 'id', "find accessions to include select")->click(); + sleep(1); + $t->find_element_ok('option[value="11"]', "css", "find accession value for list")->click(); + sleep(1); + $t->find_element_ok('crbd_list_of_checks_section_list_select', 'id', "find accessions to include select")->click(); + sleep(1); + $t->find_element_ok('//select[@id="crbd_list_of_checks_section_list_select"]//option[contains(@value, "4")]', "xpath", "find checks for list")->click(); + sleep(1); + + $t->find_element_ok('//div[@class="panel-body"]//ol//li[@class="workflow-focus"]//center//button[text()="Continue to Next Step"]', + 'xpath', 'go to next screen - Design Information')->click(); + sleep(2); + + # SCREEN 4 /Trail Linkage/ + + $t->find_element_ok('add_project_trial_sourced', 'id', "find add project trial sourced select")->click(); + $t->find_element_ok('//select[@id="add_project_trial_sourced"]//option[contains(@value, "no")]', "xpath", "select project trial source option as 'no'")->click(); + + $t->find_element_ok('add_project_trial_will_be_genotyped', 'id', "find add project trial will be genotyped select")->click(); + $t->find_element_ok('//select[@id="add_project_trial_will_be_genotyped"]//option[contains(@value, "no")]', "xpath", "select project trial will be genotyped option as 'no'")->click(); + + $t->find_element_ok('add_project_trial_will_be_crossed', 'id', "find project trial will be crossed select")->click(); + $t->find_element_ok('//select[@id="add_project_trial_will_be_crossed"]//option[contains(@value, "no")]', "xpath", "select project trial will be crossed option as 'no'")->click(); + + $t->find_element_ok('//div[@class="panel-body"]//ol//li[@class="workflow-focus"]//center//button[text()="Continue to Next Step"]', + 'xpath', 'go to next screen - Trail Linkage')->click(); + sleep(1); + + # SCREEN 5 /Field map information/ + $t->find_element_ok('fieldMap_row_number', 'id', "find field map row number input")->send_keys("1"); + $t->find_element_ok('plot_layout_format', 'id', "find plot layout format select")->click(); + $t->find_element_ok('//select[@id="plot_layout_format"]//option[contains(@value, "zigzag")]', "xpath", "find checks for list")->click(); + + $t->find_element_ok('//div[@class="panel-body"]//ol//li[@class="workflow-focus"]//center//button[text()="Continue to Next Step"]', + 'xpath', 'go to next screen - Field map information')->click(); + sleep(1); + + # SCREEN 6 /Custom plot naming/ + $t->find_element_ok('plot_prefix', 'id', "find plot prefix input")->send_keys("prefix_sel_"); + $t->find_element_ok('start_number', 'id', "find plot start number select")->click(); + $t->find_element_ok('//select[@id="start_number"]//option[contains(@value, "101")]', "xpath", "find checks for list")->click(); + $t->find_element_ok('increment', 'id', "find plot number increment input")->send_keys("2"); + + $t->find_element_ok('//div[@class="panel-body"]//ol//li[@class="workflow-focus"]//center//button[text()="Continue to Next Step"]', + 'xpath', 'go to next screen - Custom plot naming')->click(); + sleep(10); + + # SCREEN 7 /Review design/ + $t->find_element_ok('redo_trial_layout_button', 'id', "find redo randomization and click button")->click(); + sleep(10); + + $t->find_element_ok('new_trial_confirm_submit', 'id', "find new trial confirm and submit")->click(); + sleep(10); + $t->find_element_ok('button[name="create_trial_success_complete_button"]', 'css', "find success button after trial upload to database"); + + $t->find_element_ok('//div[@class="panel-body"]//div[@class="workflow-complete-message workflow-message-show"]//center//button[@name="create_trial_success_complete_button"]', + 'xpath', 'click complete button on last screen and finish a modal process')->click(); + sleep(2); + + $t->find_element_ok("refresh_jstree_html", "name", "refresh tree with new trial added")->click(); + sleep(3); + + $t->find_element_ok('//div[@id="trial_list"]//ul[@class="jstree-container-ul jstree-children"]//li//i[@class="jstree-icon jstree-ocl"]', + 'xpath', 'find a plus button to open a tree in test trails')->click(); + sleep(2); + + $t->find_element_ok("//a[contains(text(),\"$trail_name\")]", 'xpath', 'Confirm if trail exists in database and new tree after refresh')->click(); + }); + +$t->driver->close(); +done_testing(); \ No newline at end of file