
net.sf.testium.executor.webdriver.commands.GetText Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testium-selenium-plugin Show documentation
Show all versions of testium-selenium-plugin Show documentation
Selenium Plugin for the Testium Executor
The newest version!
/**
*
*/
package net.sf.testium.executor.webdriver.commands;
import java.util.ArrayList;
import net.sf.testium.executor.general.SpecifiedParameter;
import net.sf.testium.executor.webdriver.WebInterface;
import org.openqa.selenium.WebElement;
import org.testtoolinterfaces.testresult.TestStepCommandResult;
import org.testtoolinterfaces.testsuite.ParameterArrayList;
import org.testtoolinterfaces.utils.RunTimeData;
import org.testtoolinterfaces.utils.RunTimeVariable;
/**
* Command for checking the text of a WebElement
*
* @author Arjan Kranenburg
*
*/
public class GetText extends GenericSeleniumCommandExecutor {
private static final String COMMAND = "getText";
private static final String PAR_ELEMENT = "element";
private static final String PAR_VARIABLE = "variable";
private static final SpecifiedParameter PARSPEC_ELEMENT = new SpecifiedParameter(
PAR_ELEMENT, WebElement.class, false, false, true, false );
public static final SpecifiedParameter PARSPEC_VARIABLE = new SpecifiedParameter(
PAR_VARIABLE, String.class, false, true, false, false );
public GetText( WebInterface aWebInterface ) {
super( COMMAND, aWebInterface, new ArrayList() );
this.addParamSpec( PARSPEC_ELEMENT );
this.addParamSpec( PARSPEC_VARIABLE );
}
@Override
protected void doExecute(RunTimeData aVariables,
ParameterArrayList parameters, TestStepCommandResult result)
throws Exception {
WebElement element = obtainElement( aVariables, parameters, PARSPEC_ELEMENT );
String varName = (String) obtainValue(aVariables, parameters, PARSPEC_VARIABLE);
String text = CheckText.getActualText(element);
result.setDisplayName( this.toString() + " " + varName + "=\"" + text + "\"" );
RunTimeVariable rtVariable = new RunTimeVariable( varName, text );
aVariables.add(rtVariable);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy