@@ -156,54 +156,6 @@ public void setDefaultTimeout() {
156156 }
157157 }
158158
159- @ Action (object = ObjectType .BROWSER , desc = "Add a variable to access within testcase" , input = InputType .YES , condition = InputType .YES )
160- public void AddVar () {
161- String stringOpration = Input .split ("\\ (" , 2 )[0 ].replace ("=" , "" ).trim ();
162- switch (stringOpration ) {
163- case "Replace" :
164- replaceFunction ();
165- break ;
166- case "Split" :
167- splitFunction ();
168- break ;
169- case "Substring" :
170- subStringFunction ();
171- break ;
172- default :
173- addVar (Condition , Data );
174- break ;
175- }
176- if (getVar (Condition ) != null ) {
177- Report .updateTestLog ("addVar" , "Variable " + Condition + " added with value " + Data , Status .DONE );
178- } else {
179- Report .updateTestLog ("addVar" , "Variable " + Condition + " not added " , Status .DEBUG );
180- }
181- }
182-
183- @ Action (object = ObjectType .BROWSER , desc = "Add a Global variable to access across test set" , input = InputType .YES , condition = InputType .YES )
184- public void AddGlobalVar () {
185- //Added for Replace, Split and Substring functions to work with AddGlobalVar
186- String stringOpration = Input .split ("\\ (" , 2 )[0 ].replace ("=" , "" ).trim ();
187- switch (stringOpration ) {
188- case "Replace" :
189- replaceFunction ();
190- break ;
191- case "Split" :
192- splitFunction ();
193- break ;
194- case "Substring" :
195- subStringFunction ();
196- break ;
197- default :
198- addGlobalVar (Condition , Data );
199- break ;
200- }
201- if (getVar (Condition ) != null ) {
202- Report .updateTestLog (Action , "Variable " + Condition + " added with value " + Data , Status .DONE );
203- } else {
204- Report .updateTestLog (Action , "Variable " + Condition + " not added " , Status .DEBUG );
205- }
206- }
207159
208160 @ Action (object = ObjectType .BROWSER , desc = "Changes the browser size into [<Data>]" , input = InputType .YES )
209161 public void setViewPortSize () {
@@ -437,35 +389,6 @@ public void storeElementCSSValueinVariable() {
437389 }
438390 }
439391
440- @ Action (object = ObjectType .BROWSER , desc = "store variable value [<Condition>] in data sheet[<Data>]" , input = InputType .YES , condition = InputType .YES )
441- public void storeVariableInDataSheet () {
442- if (Input != null && Condition != null ) {
443- if (!getVar (Condition ).isEmpty ()) {
444- System .out .println (Condition );
445- String [] sheetDetail = Input .split (":" );
446- String sheetName = sheetDetail [0 ];
447- String columnName = sheetDetail [1 ];
448- userData .putData (sheetName , columnName , getVar (Condition ));
449- Report .updateTestLog (Action ,
450- "Value of variable " + Condition + " has been stored into " + "the data sheet" , Status .DONE );
451- } else {
452- Report .updateTestLog (Action , "The variable " + Condition + " does not contain any value" , Status .FAIL );
453- }
454- } else {
455- Report .updateTestLog (Action , "Incorrect input format" , Status .DEBUG );
456- System .out .println ("Incorrect input format " + Condition );
457- }
458- }
459-
460- @ Action (object = ObjectType .BROWSER , desc = "store value [<Data>] in Variable [<Condition>]" , input = InputType .YES , condition = InputType .YES )
461- public void storeVariable () {
462- if (Condition .startsWith ("%" ) && Condition .endsWith ("%" )) {
463- addVar (Condition , Data );
464- Report .updateTestLog (Action , "Value" + Data + "' is stored in Variable '" + Condition + "'" , Status .DONE );
465- } else {
466- Report .updateTestLog (Action , "Variable format is not correct" , Status .DEBUG );
467- }
468- }
469392
470393 private void PlaywrightExceptionLogging (PlaywrightException e ) {
471394 Report .updateTestLog (Action , "Unique Element [" + ObjectName + "] not found on Page. Error :" + e .getMessage (),
@@ -474,159 +397,4 @@ private void PlaywrightExceptionLogging(PlaywrightException e) {
474397 throw new ActionException (e );
475398 }
476399
477- public void replaceFunction () {
478- String op = "" ;
479- String original = "" ;
480- String targetString = "" ;
481- String replaceString = "" ;
482- String occurance = "" ;
483- String [] args2 = null ;
484- String args1 = Input .split ("Replace\\ (" )[1 ];
485- if (args1 .substring (args1 .length () - 1 ).equals (":" )) {
486- args2 = args1 .substring (0 , args1 .length () - 2 ).split (",'" );
487- } else {
488- args2 = args1 .substring (0 , args1 .length () - 1 ).split (",'" );
489- }
490- targetString = args2 [1 ].substring (0 , args2 [1 ].length () - 1 );
491- replaceString = args2 [2 ].split ("'," )[0 ];
492- occurance = args2 [2 ].split ("'," )[1 ];
493- Pattern pattern = Pattern .compile ("%.*%" );
494- Matcher matcher = pattern .matcher (args2 [0 ]);
495- if (matcher .find ()) {
496- original = getVar (args2 [0 ]);
497- } else {
498- original = args2 [0 ].substring (1 , args2 [0 ].length () - 1 );
499- }
500- try {
501- if (args2 .length > 0 ) {
502- if (occurance .toLowerCase ().equals ("first" )) {
503- System .out .println ("original " + original );
504- System .out .println ("targetString " + targetString );
505- System .out .println ("replaceString " + replaceString );
506- System .out .println ("occurance " + occurance );
507-
508- op = original .replaceFirst (targetString , replaceString );
509- } else {
510- System .out .println ("original " + original );
511- System .out .println ("targetString " + targetString );
512- System .out .println ("replaceString " + replaceString );
513- System .out .println ("occurance " + occurance );
514- op = original .replace (targetString , replaceString );
515- }
516- }
517-
518- } catch (Exception ex ) {
519- ex .printStackTrace ();
520- }
521- switch (Action ) {
522- case "AddGlobalVar" :
523- addGlobalVar (Condition , op );
524- break ;
525- case "AddVar" :
526- addVar (Condition , op );
527- break ;
528- }
529- }
530-
531- public void splitFunction () {
532- try {
533- String op = "" ;
534- String original = "" ;
535- String regex = "" ;
536- String stringIndex = "" ;
537- String splitLength = "" ;
538- String [] args2 = null ;
539- String [] stringSplit = null ;
540- String args1 = Input .split ("Split\\ (" )[1 ];
541-
542- if (args1 .substring (args1 .length () - 1 ).equals (":" )) {
543- args2 = args1 .substring (0 , args1 .length () - 2 ).split (",'" );
544- } else {
545- args2 = args1 .substring (0 , args1 .length () - 1 ).split (",'" );
546- }
547- regex = args2 [1 ].split ("'," )[0 ];
548- Pattern pattern = Pattern .compile ("%.*%" );
549- Matcher matcher = pattern .matcher (args2 [0 ]);
550- if (matcher .find ()) {
551- original = getVar (args2 [0 ]);
552- } else {
553- original = args2 [0 ].substring (1 , args2 [0 ].length () - 1 );
554- }
555- if (!(args2 [1 ].split ("'," )[1 ]).contains ("," )) {
556- stringIndex = args2 [1 ].split ("'," )[1 ];
557- stringSplit = original .split (regex );
558- } else {
559- stringIndex = args2 [1 ].split ("'," )[1 ].split ("," )[1 ];
560- splitLength = args2 [1 ].split ("'," )[1 ].split ("," )[0 ];
561- stringSplit = original .split (regex , Integer .parseInt (splitLength ));
562- }
563- op = stringSplit [Integer .parseInt (stringIndex )];
564-
565- switch (Action ) {
566- case "AddGlobalVar" :
567- addGlobalVar (Condition , op );
568- break ;
569- case "AddVar" :
570- addVar (Condition , op );
571- break ;
572- }
573-
574- } catch (Exception e ) {
575- e .printStackTrace ();
576- }
577- }
578-
579- public void subStringFunction () {
580- try {
581- String op = "" ;
582- String original = "" ;
583- String startIndex = "" ;
584- String endIndex = "" ;
585- String [] args2 = null ;
586- String args1 = Input .split ("Substring\\ (" )[1 ];
587-
588- if (args1 .substring (args1 .length () - 1 ).equals (":" )) {
589- args2 = args1 .substring (0 , args1 .length () - 2 ).split ("," );
590- } else {
591- args2 = args1 .substring (0 , args1 .length () - 1 ).split ("," );
592- }
593- Pattern pattern = Pattern .compile ("%.*%" );
594- Matcher matcher = pattern .matcher (args2 [0 ]);
595- if (matcher .find ()) {
596- original = getVar (args2 [0 ]);
597- startIndex = args2 [1 ];
598- if (args2 .length == 3 ) {
599- endIndex = args2 [2 ];
600- }
601- } else {
602- String [] args3 = args1 .substring (0 , args1 .length () - 2 ).split ("'," );
603- original = args3 [0 ].substring (1 , args2 [0 ].length () - 1 );
604- if (args3 [1 ].contains ("," )) {
605- startIndex = args3 [1 ].split ("," )[0 ];
606- endIndex = args3 [1 ].split ("," )[1 ];
607- } else {
608- startIndex = args3 [1 ];
609- }
610- }
611-
612- if (endIndex .equals ("" )) {
613- op = original .substring (Integer .parseInt (startIndex ));
614- } else {
615- op = original .substring (Integer .parseInt (startIndex ), Integer .parseInt (endIndex ));
616- }
617-
618- switch (Action ) {
619- case "AddGlobalVar" :
620- addGlobalVar (Condition , op );
621- break ;
622- case "AddVar" :
623- addVar (Condition , op );
624- break ;
625- }
626-
627- } catch (Exception e ) {
628- e .printStackTrace ();
629- }
630- }
631-
632400}
0 commit comments