Yes, I'm using the snapshots from last night. The getText is working
now with the code that I posted (after I made the module definition
fix that I posted) but the tellurium engine had to be off. I do have
pauses in the code. I also had to turn the tellurium engine off for
clicking on all of the checkboxes on a form or otherwise only some of
the checkboxes would be checked.
Here's my code for that:
public static void setCheckboxOptions(final DslContext context,
final String listUid, final boolean checked) {
int size = context.getListSizeBySelector(listUid);
for (int i = 1; i <= size; i++) {
setCheckbox(checked, context, "${listUid}[${i}]");
}
}
public static void setCheckbox(final boolean on, final DslContext
context,
final String elementUid) {
String elementValue = (String) context
.getAttribute(elementUid, "value");
boolean isChecked = context.isChecked(elementUid);
// Since the html is sometimes returning "true" and other times
"checked" -- this
// code is more complex than it should have to be.
log.debug("setCheckbox ${elementValue}")
// If not set to the allow value, then click the button.
if (on && !isChecked || (!on && isChecked)) {
context.click(elementUid);
context.pause(VireoTestConfig.getPauseTime());
//
context.waitForPageToLoad(VireoTestConfig.getMaxWait()); //
// comment
// out?
// Make sure the value is what we set it to.
String condition = ""
if (on) {
condition = "isChecked(\"${elementUid}\");";
} else {
condition = "!isChecked(\"${elementUid}\");";
}
log.info("setCheckbox: " + condition);
context.waitForCondition(condition,
VireoTestConfig.getMaxWait());
context.pause(VireoTestConfig.getPauseTime());
// TestingUtils.waitForAjax(selenium,
VireoTestConfig.getMaxWait());
}
}
and the test calling it sets the TelluriumEngine to off:
@BeforeClass
public static void initUi() {
dlam = new DspaceLogonAdminModule();
dlam.defineUi();
connectSeleniumServer();
useTelluriumEngine(false);
...
Jade
On Sep 9, 4:08 pm, Jian Fang <[email protected]> wrote:
> Thanks for the details.
>
> The click did not work even for the latest snapshot from last night? That is
> really wired.
>
> If you turn off the Engine, the getValue is called on Selenium APIs. I
> wonder if your problem is caused by
> the fact that you could not get back the correct value right away since it
> takes some time
> for the value to be changed after the click event. Have you ever tried to
> add some delay such as
>
> pause(1000)
>
> in the command or try some waitForCondition() command?
>
> Thanks,
>
> Jian
>
> On Thu, Sep 9, 2010 at 4:53 PM, Jade <[email protected]> wrote:
> > Hi Jian,
>
> > The previous error was due to the selenium engine not finding the html
> > element. I changed the module definition to fix that problem.
>
> > I had to turn the tellurium engine off otherwise the test wouldn't
> > modify the value since the click method didn't cause the UI to click
> > on the item, thus it wasn't selected and these lines didn't do
> > anything:
>
> > if (value.isEmpty()) {
> > module.type(inputUid, " ");
> > } else {
> > module.type(inputUid, value);
> > }
>
> > Here's my method to test changing values on clickable text fields:
>
> > public static void testEditingClickableField(final String textUid,
> > final String inputUid, final String value,
> > final DslContext module, final boolean isValid) {
>
> > log.info "testEditingClickableField ${textUid}"
> > // If not disabled, value won't change b/c element won't be
> > clicked.
> > module.disableTelluriumEngine()
>
> > String originalText = module.getText(textUid); // getValue
> > is only
> > valid if value= is viewable in the html
> > // such as <input
> > id="aspect_vireo_admin_View_field_firstName"
> > class="ds-text-field firstName editable" name="firstName" type="text"
> > value="New First Name" />
> > // in the code, the value is often not set.
>
> > if (!originalText.equals(value)) {
>
> > // If the value is blank, then Vireo sometimes
> > displays none.
> > final String NONE = "none"
>
> > boolean successful = false;
> > int maxTries = 5;
> > int tries = 0;
>
> > String currentTextValue
> > String currentInputTextValue
>
> > // Due to ajax timing issues, try more than once to
> > perform this
> > action.
> > while (!successful && tries++ < maxTries) {
> > // click on the textUid to trigger the ajax
> > / javascript to allow
> > the value to be changed.
> > clickFakeItem(textUid, inputUid, module,
> > true)
>
> > if (value.isEmpty()) {
> > module.type(inputUid, " ");
> > } else {
> > module.type(inputUid, value);
> > }
>
> > module.pause(VireoTestConfig.getPauseTime());
> > currentTextValue = module.getText(textUid)
> > //clickFakeItem(textUid, inputUid, module,
> > true)
> > module.mouseOut textUid
>
> > log.info "try ${tries}:
> > testEditingClickableField
> > currentTextValue: ${currentTextValue} newValue: ${value} origText: $
> > {originalText}"
>
> > if (isValid) {
> > if ((value.isEmpty() &&
> > currentTextValue.equals(NONE)) ||
> > currentTextValue.equals(value)) {
> > successful = true
> > }
> > } else {
> > if
> > (currentTextValue.equals(originalText)) {
> > successful = true
> > }
> > }
> > }
>
> > if (isValid) {
>
> > if ((value.isEmpty() &&
> > (!(currentTextValue.equals(NONE) ||
> > currentTextValue.isEmpty()))) ||
> > (!value.isEmpty() &&
> > !currentTextValue.equals(value))) {
> > log.error("${textUid} wasn't updated
> > to ${value} or ${NONE}. Its
> > current text is ${currentTextValue}")
> > }
> > } else {
> > if (!originalText.equals(currentTextValue))
> > {
> > log.error("${textUid} shouldn't have
> > been updated to ${value} or $
> > {NONE}. originalValue: ${originalText}, currentText: $
> > {currentTextValue}")
> > }
> > }
> > }
> > module.enableTelluriumEngine()
> > }
>
> > and my module def:
>
> > String postAction = "\"${VireoTestConfig.getWebApp()}/vireo/admin/
> > detail?update=true\""
>
> > public void defineModule() {
>
> > ui.Form(uid: "DegreeInformationForm", clocator: [tag:
> > "form",
> > method: "post", action: "${postAction}", class: "ds-interactive-div
> > view-form", id: "aspect_vireo_admin_View_div_view-form"]) {
>
> > TextBox(uid: "committee_member_2", clocator: [tag:
> > "span", class:
> > "group-committee-", id: "aspect_vireo_admin_View_field_committee-
> > member-2"], respond: ["click"])
> > TextBox(uid: "committee_member_1", clocator: [tag:
> > "span", class:
> > "group-committee-", id: "aspect_vireo_admin_View_field_committee-
> > member-1"], respond: ["click"])
> > TextBox(uid: "school", clocator: [tag: "span", id:
> > "aspect_vireo_admin_View_field_school", type: "text"], respond:
> > ["click"])
>
> > Selector(uid: "degree", clocator: [id:
> > "aspect_vireo_admin_View_field_degree"], respond: ["click"])
>
> > TextBox(uid: "committee_email", clocator: [tag:
> > "span", class:
> > "committee-email", id: "aspect_vireo_admin_View_field_committee-
> > email"], respond: ["click"])
>
> > TextBox(uid: "department", clocator: [tag: "span",
> > id:
> > "aspect_vireo_admin_View_field_department", type: "text"], respond:
> > ["click"])
>
> > Selector(uid: "college", clocator: [id:
> > "aspect_vireo_admin_View_field_college"], respond: ["click"])
> > Selector(uid: "degreeLevel", clocator: [id:
> > "aspect_vireo_admin_View_field_degreeLevel"], respond: ["click"])
>
> > TextBox(uid: "committee_member_3", clocator: [tag:
> > "span", class:
> > "group-committee-", id: "aspect_vireo_admin_View_field_committee-
> > member-3", type: "text"], respond: ["click"])
> > TextBox(uid: "discipline", clocator: [tag: "span",
> > id:
> > "aspect_vireo_admin_View_field_discipline", type: "text"], respond:
> > ["click"])
> > TextBox(uid: "semester", clocator: [tag: "span", id:
> > "aspect_vireo_admin_View_field_semester", type: "text"], respond:
> > ["click"])
> > }
>
> > //Since ajax changes the html when a list is clicked, this
> > module is
> > required to represent clickable lists once they've been clicked.
> > // For more information, see:
>
> >http://groups.google.com/group/tellurium-users/browse_thread/thread/9...
> > //
> > ui.Form(uid: "DegreeInformationClickedForm", clocator: [tag:
> > "form",
> > method: "post", action: "${postAction}", class: "ds-interactive-div
> > view-form", id: "aspect_vireo_admin_View_div_view-form"]) {
>
> > Selector(uid: "degreeSelector", clocator: [id:
> > "aspect_vireo_admin_View_field_degree"], respond: ["click"])
> > Selector(uid: "collegeSelector", clocator: [id:
> > "aspect_vireo_admin_View_field_college"], respond: ["click"])
> > Selector(uid: "degreeLevelSelector", clocator: [id:
> > "aspect_vireo_admin_View_field_degreeLevel"], respond: ["click"])
>
> > InputBox(uid: "committee_emailClicked", clocator:
> > [tag: "input",
> > id: "aspect_vireo_admin_View_field_committee-email", type: "text"],
> > respond: ["click"])
> > InputBox(uid: "committee_member_2Clicked", clocator:
> > [tag: "input",
> > id: "aspect_vireo_admin_View_field_committee-member-2", type: "text"],
> > respond: ["click"])
> > InputBox(uid: "committee_member_1Clicked", clocator:
> > [tag: "input",
> > id: "aspect_vireo_admin_View_field_committee-member-1", type: "text"],
> > respond: ["click"])
> > InputBox(uid: "committee_member_3Clicked", clocator:
> > [tag: "input",
> > id: "aspect_vireo_admin_View_field_committee-member-3", type: "text"],
> > respond: ["click"])
>
> > InputBox(uid: "schoolClicked", clocator: [tag:
> > "input", id:
> > "aspect_vireo_admin_View_field_school", type: "text"], respond:
> > ["click"])
> > InputBox(uid: "disciplineClicked", clocator: [tag:
> > "input", id:
> > "aspect_vireo_admin_View_field_discipline", type: "text"], respond:
> > ["click"])
> > InputBox(uid: "semesterClicked", clocator: [tag:
> > "input", id:
> > "aspect_vireo_admin_View_field_semester", type: "text"], respond:
> > ["click"])
> > InputBox(uid: "departmentClicked", clocator: [tag:
> > "input", id:
> > "aspect_vireo_admin_View_field_department", type: "text"], respond:
> > ["click"])
> > }
>
> > and my data input file:
>
> > verifyModule|1
>
> > ## Format of test data for edit_ tests where textboxes are edited.
> > ## testName | dataField |submissionId | name | is valid data?
> > edit_committee_email|1||true
> > edit_committee_email|1|new value|true
> > edit_committee_email|1|9|true
>
> ...
>
> read more »
--
You received this message because you are subscribed to the Google Groups
"tellurium-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tellurium-users?hl=en.