88import org .openqa .selenium .WebDriver ;
99import org .openqa .selenium .WebElement ;
1010import org .openqa .selenium .interactions .Actions ;
11+ import org .openqa .selenium .support .ui .Select ;
1112
1213import java .util .HashMap ;
1314import java .util .Map ;
@@ -37,55 +38,65 @@ public void createWellGroup(String type, String name)
3738 {
3839 selectTypeTab (type );
3940
40- WebElement nameField = Locator .tagWithName ("input" , "wellGroupName" )
41- .withAttribute ("data-type" , type )
42- .findElement (getDriver ());
43- setFormElement (nameField , name );
44- fireEvent (nameField , SeleniumEvent .change );
41+ // Wait for the create row to be visible (canAdd must be true for this type)
42+ WebElement newNameInput = Locator .css (".group-types-panel__new-name-input" )
43+ .waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT );
44+
45+ if ("input" .equalsIgnoreCase (newNameInput .getTagName ()))
46+ {
47+ setFormElement (newNameInput , name );
48+ }
49+ else
50+ {
51+ new Select (newNameInput ).selectByVisibleText (name );
52+ }
53+
4554 clickButton ("Create" , 0 );
46- waitForElement (Locator .tagContainingText ( "label" , name ));
55+ waitForElement (Locator .css ( ".group-types-panel__group-name" ). withText ( name ));
4756 }
4857
4958 public void selectTypeTab (String name )
5059 {
51- Locator .tagWithClass ("div" , "gwt-Label" ).withText (name ).waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT ).click ();
60+ Locator .css (".group-types-panel__tab" ).withText (name )
61+ .waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT ).click ();
62+ }
63+
64+ public void selectGroup (String name )
65+ {
66+ Locator .css (".group-types-panel__group-name" ).withText (name )
67+ .waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT ).click ();
5268 }
5369
5470 public void selectWellsForWellgroup (String type , String wellGroup , String startLocation , String endLocation )
5571 {
5672 selectTypeTab (type );
57- waitForElement (Locator .tagWithText ("label" , wellGroup ));
5873
59- Locator start = Locator .css (".Cell-" +startLocation );
60- Locator end = Locator .css (".Cell-" +endLocation );
61- if (wellGroup != null & !"" .equals (wellGroup ))
74+ if (wellGroup != null && !wellGroup .isEmpty ())
6275 {
63- if (!getText (Locator .css (".gwt-TabBarItem-selected" )).equals (type ))
64- {
65- Locator .css (".gwt-Label" ).withText (type ).findElement (getDriver ()).click ();
66- //want for switch
67- }
68- if (!isChecked (Locator .xpath ("//input[@name='wellGroup' and following-sibling::label[text()='" +wellGroup +"']]" )))
69- click (Locator .xpath ("//input[@name='wellGroup' and following-sibling::label[text()='" +wellGroup +"']]" ));
70- if (!getAttribute (start , "style" ).contains ("rgb(255, 255, 255)" ))
71- click (start );
72- }
73- else
74- {
75- Locator .tagWithClass ("*" , "gwt-Label" ).withText (type ).findElement (getDriver ()).click ();
76- //select no group in order to clear area
76+ selectGroup (wellGroup );
7777 }
78- WebElement fromEl = start .findElement (getDriver ());
79- WebElement toEl = end .findElement (getDriver ());
78+
79+ // Cells are <td> elements with aria-label matching the location (e.g. "A1" or "A1: Specimen 1")
80+ WebElement fromEl = Locator .css (".template-grid__cell[aria-label^='" + startLocation + "']" )
81+ .waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT );
82+ WebElement toEl = Locator .css (".template-grid__cell[aria-label^='" + endLocation + "']" )
83+ .waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT );
8084
8185 Actions builder = new Actions (getDriver ());
8286 builder .clickAndHold (fromEl ).moveToElement (toEl ).release ().build ().perform ();
8387 }
8488
89+ public void setWellGroupProperty (String propertyKey , String value )
90+ {
91+ WebElement input = Locator .tag ("input" ).withAttribute ("aria-label" , propertyKey )
92+ .waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT );
93+ setFormElement (input , value );
94+ }
95+
8596 public void setName (String name )
8697 {
87- Locator nameField = Locator .id ( "templateName" );
88- waitForElement (nameField , WAIT_FOR_JAVASCRIPT );
98+ WebElement nameField = Locator .css ( ".plate-template-designer__name-input" )
99+ . waitForElement (getDriver () , WAIT_FOR_JAVASCRIPT );
89100 setFormElement (nameField , name );
90101 fireEvent (nameField , SeleniumEvent .change );
91102 }
@@ -100,13 +111,18 @@ public void save()
100111 clickButton ("Save" , 0 );
101112 }
102113
114+ public void cancel ()
115+ {
116+ clickButton ("Cancel" );
117+ }
118+
103119 @ Override
104120 protected ElementCache newElementCache ()
105121 {
106122 return new ElementCache ();
107123 }
108124
109- protected class ElementCache extends LabKeyPage .ElementCache
125+ protected class ElementCache extends LabKeyPage <?> .ElementCache
110126 {
111127 }
112128
0 commit comments