okw.fourTestLocator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
This is the core-module of OpenKeyWord. This module is automatically integrated by the adapters. In GUI automation, the core module is automatically integrated by the GUI modules (dependencies).
The newest version!
package okw;
import okw.log.Logger_Sngltn;
public class fourTestLocator
{
/**
* \copydoc CurrentObject::Log()
*/
private static Logger_Sngltn Log = Logger_Sngltn.getInstance();
public fourTestLocator( String fspL )
{
super();
this.get4TestLocator( fspL );
}
private String cvsGUIClass = null;
private String cvsLocator = null;
/**
* Erzeugt einen locator aus dem gegebenen Wert, wenn fspL mit "4T!", "4T:" oder "4T?" anfängt, sonst wird fspL unverändert zuräckgegeben.
*
* @note
* 1. fpsL = "//div[@ID='myID']"
-> return = "//div[@ID='myID']"
- ohne "4T*!"- Präfix wird die XPath.Angabe unverändert durchgelassen
* 2. fpsL = "4T!MyValue"
-> return = "//*[@@data-harmony-id='MyValue']"
- Locator mit dem Attribute "data-4Test" wird erzeugt.
* 3. fpsL = "4TNA!MyValue"
-> return = "//*[contains( @name, 'MyValue']"
- Locator mit dem Attribute "name" wird erzeugt.
* 4. fpsL = "4TAI!MyValue"
-> return = "//*[contains( @AutomationID, 'MyValue']"
- Locator mit dem Attribute "AutomationID" wird erzeugt.
* 5. fpsL = "4TID!MyValue"
-> return = "//*[contains( @ID, 'MyValue']"
- Locator mit dem Attribute "ID" wird erzeugt.
* 6. fpsL = "4TLA!MyValue"
-> return = "//label[contains(text(),'MyValue')]/following-sibling::input"
* 7. fpsL = "4TTX!MyValue"
-> return = "//*[contains(text(),'MyValue')]"
- Locator Tag mit dem gegebene Text wird erzeugt.
*
* @param fspL Locator Parameter
* @return Erzeugter data-4Test Locator oder unveränderter fpsL-Wert.
*/
public String get4TestLocator( String fpsL )
{
String lvsReturn = fpsL;
String LogMessage = "";
if ( fpsL.startsWith("4T!") )
{
// Find object with data-4test attribute
LogMessage = "Generate '@data-harmony-id' Locator";
seperateClassnameAndLocator( fpsL.replaceFirst("4T!", "" ) );
lvsReturn = "//*[@data-harmony-id=\"" + this.cvsLocator + "\"]";
}
else if ( fpsL.startsWith("4TAI!") )
{
// Find object with label than contains text
LogMessage = "Generate '@AutomationID' Locator";
seperateClassnameAndLocator( fpsL.replaceFirst("4TAI!", "" ) );
lvsReturn = "//*[@AutomationID='" + this.cvsLocator + "']";
}
else if ( fpsL.startsWith("4TNA!") )
{
// Find object with label than contains text
LogMessage = "Generate '@name' Locator";
seperateClassnameAndLocator( fpsL.replaceFirst("4TNA!", "" ) );
lvsReturn = "//*[contains(@name,'" + this.cvsLocator + "')]";
}
else if ( fpsL.startsWith("4TID!") )
{
// Find object with label than contains text
LogMessage = "Generate '@id' Locator";
seperateClassnameAndLocator( fpsL.replaceFirst("4TID!", "" ) );
lvsReturn = "//*[contains(@id,'" + this.cvsLocator + "')]";
}
else if ( fpsL.startsWith("4TLA!") )
{
// Find object with label than contains text
LogMessage = "Generate 'label' Locator";
seperateClassnameAndLocator( fpsL.replaceFirst("4TLA!", "" ) );
lvsReturn = "//label[contains(text(),'" + this.cvsLocator + "')]/following-sibling::input";
}
else if ( fpsL.startsWith("4TTX!") )
{
// Find object with label than contains text
LogMessage = "Generate 'Contains Text' Locator";
seperateClassnameAndLocator( fpsL.replaceFirst("4TTX!", "" ) );
lvsReturn = "//*[contains(text(),'" + this.cvsLocator + "')]";
}
this.cvsLocator = lvsReturn;
Log.LogPrint( LogMessage );
return lvsReturn;
}
/**
* Trennt den Klassenbezeichner vom Locator ab.
*
* "Myclass::myLocator"
* "MyLocator"
*
* @param fpsLocator
* @return
*/
public int seperateClassnameAndLocator( String fpsLocator )
{
int iReturn = 0;
String[] MySplit = fpsLocator.split("::");
if ( MySplit.length == 1 )
{
cvsLocator = MySplit[0];
}
else if ( MySplit.length == 2 )
{
cvsGUIClass= MySplit[0];
cvsLocator = MySplit[1];
}
else
{
iReturn = -1;
}
return iReturn;
}
public String getGUIClass() {
return cvsGUIClass;
}
public String getLocator()
{
return cvsLocator;
}
}