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/994b889df6140bc1/5529f3dd9607fbec#5529f3dd9607fbec
//
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
edit_school|1||true
edit_school|1|new value|true
edit_school|1|9|true
edit_committee_member_2|1||true
edit_committee_member_2|1|new value|true
edit_committee_member_2|1|9|true
edit_department|1||false
edit_department|1|new value|true
edit_department|1|9|true
edit_committee_member_1|1||true
edit_committee_member_1|1|new value|true
edit_committee_member_1|1|9|true
edit_committee_member_3|1||true
edit_committee_member_3|1|new value|true
edit_committee_member_3|1|9|true
edit_discipline|1||false
edit_discipline|1|new value|true
edit_discipline|1|9|true
edit_semester|1||true
edit_semester|1|new value|true
edit_semester|1|9|true
## Format of test data for test_ tests where items are selected from
lists.
## testName | submissionId | indexToTest or -1 if test all |
firstValidIndex | shouldTestFail?
test_degree|1|-1|1|false
test_degree|1|1|1|false
test_college|1|-1|1|false
test_college|1|1|1|false
test_degreeLevel|1|-1|1|true
test_degreeLevel|1|1|1|true
Jade
On Sep 9, 1:55 pm, Jian Fang <[email protected]> wrote:
> No, I don't need the screenshots. But it would help me to find the problem
> if you
> could provide more details such as the log, the old value, the new value,
> the code snippet
> that issues the getText method etc.
>
> Thanks,
>
> Jian
>
> On Thu, Sep 9, 2010 at 2:51 PM, Jade <[email protected]> wrote:
> > Hi Jian,
>
> > Many of my tests are working but one that updates a clickable InputBox
> > is not. The value is updated but then the getText() method doesn't
> > return the new value. Ajax is used. I have screenshots if you'd like
> > to see them.
>
> > Jade
>
> > On Sep 9, 8:38 am, Jade <[email protected]> wrote:
> > > You're awesome! Thank you so much Jian. I'll try them out today.
>
> > > Jade
>
> > > On Sep 8, 9:27 pm, Jian Fang <[email protected]> wrote:
>
> > > > Ok, I added mouse and key events to the delegation list to Selenium.
> > Now,
> > > > you can simply call
>
> > > > useTelluriumEngine(true)
>
> > > > and then try your tab test case with the following artifacts:
>
> > > >http://maven.kungfuters.org/content/repositories/snapshots/org/seleni.
> > ..
>
> > > >http://maven.kungfuters.org/content/repositories/snapshots/org/tellur.
> > ..
>
> > > > Thanks,
>
> > > > Jian
>
> > > > On Wed, Sep 8, 2010 at 8:55 PM, Jian Fang <[email protected]>
> > wrote:
> > > > > keyUp and keyDown are not exposed in 0.7.0, but you can use
>
> > > > > def keyType(String uid, def input)
>
> > > > > which will fire different key events such as keyUp and keyDown to
> > simulate
> > > > > user's behavior.
>
> > > > > Thanks,
>
> > > > > Jian
>
> > > > > On Wed, Sep 8, 2010 at 5:29 PM, Jade <[email protected]> wrote:
>
> > > > >> Hi Jian,
>
> > > > >> Thanks very much for the information! That will help a lot with my
> > > > >> testing.
>
> > > > >> I'm still trying to figure out how to simulate pressing the tab key.
>
> > > > >> Apparently keyUp and keyDown aren't avail in 0.7.0 and I've moved
> > back
> > > > >> to that version temporarily. Any ideas?
>
> > > > >> Jade
>
> > > > >> On Sep 8, 9:40 am, Jian Fang <[email protected]> wrote:
> > > > >> > No, that is not true. Tellurium works in two modes:
>
> > > > >> >http://code.google.com/p/aost/wiki/TelluriumAWrapOfSelenium
>
> > > > >> > 1) Selenium wrapper: Tellurium core generates runtime locators
> > from UI
> > > > >> > modules, then
> > > > >> > call Selenium APIs. That is to say:
>
> > > > >> > Tellurium core --> UI module --> runtime locator --> Selenium
> > APIs with
> > > > >> > locator
>
> > > > >> > 2) Tellurium way: Tellurium Engine does UI module locating and
> > call
> > > > >> > Tellurium APIs.
>
> > > > >> > Tellurium Core --> Pass UI module --> Tellurium Engine does UI
> > module
> > > > >> > locating
> > > > >> > Tellurium Core --> UID based call --> Tellurium APIs.
>
> > > > >> > If you call useTelluriumEngine(false), you are running in mode 1),
> > > > >> > otherwise, it is in mode 2.
>
> > > > >> > Even in mode 1), you still benefit from the UI module definition,
> > css
> > > > >> > selector, and some new APIs in term of
> > > > >> > Selenium extension.
>
> > > > >> > Thanks,
>
> > > > >> > Jian
>
> > > > >> > On Wed, Sep 8, 2010 at 10:30 AM, Jade <[email protected]> wrote:
> > > > >> > > Hi Jian,
>
> > > > >> > > Thank you for the information. I'm still unclear about a few
> > items.
>
> > > > >> > > The reason that I started using tellurium is because certain
> > tests
> > > > >> > > such as clicking on all checkboxes in a form weren't working
> > with
> > > > >> > > selenium. In addition, I liked the separation of the module
> > > > >> > > definitions from the test code. Since the tellurium engine isn't
> > > > >> > > working at times with ajax, I've turned it off but then I'm
> > unclear
> > > > >> > > about when exactly I need to turn it back on? From your message,
> > I'm
> > > > >> > > afraid that I won't be able to use the module definitions when
> > the
> > > > >> > > tellurium engine is off. Is that correct?
>
> > > > >> > > Jade
>
> > > > >> > > On Sep 8, 9:04 am, Jian Fang <[email protected]> wrote:
> > > > >> > > > Hi Jade,
>
> > > > >> > > > I understand your confusion. 0.7.0 was designed in a way for
> > > > >> Selenium
> > > > >> > > APIs
> > > > >> > > > to reuse the
> > > > >> > > > caching mechanism in the Tellurium new Engine, thus, many
> > options
> > > > >> are
> > > > >> > > > provided to fine
> > > > >> > > > tune the framework behavior. But now, seems this is a bit
> > > > >> over-design and
> > > > >> > > > could cause a lot of
> > > > >> > > > confusions. As a result, in 0.8.0, Selenium APIs will not be
> > coupled
> > > > >> with
> > > > >> > > > Tellurium Engine
> > > > >> > > > that is to say,
>
> > > > >> > > > Selenium APIs: CSS/XPath selector, no caching mechanism
> > > > >> > > > Tellurium APIs: UI module locating, caching mechanism
>
> > > > >> > > > With that, useTelluriumEngine(boolean isUse) should be enough
> > to
> > > > >> switch
> > > > >> > > > between Tellurium APIs
> > > > >> > > > and Selenium APIs.
>
> > > > >> > > > useTelluriumEngine(false) and useTelluriumApi(true) seem to
> > use
> > > > >> Tellurium
> > > > >> > > > APIs, but turn off
> > > > >> > > > the caching mechanism, which worked one week ago. With the
> > latest
> > > > >> update
> > > > >> > > of
> > > > >> > > > using UIDs, not
> > > > >> > > > locators for Tellurium APIs, TelluriumAPIs must work with
> > caching.
> > > > >> That
> > > > >> > > is
> > > > >> > > > why you cannot do
> > > > >> > > > that now.
>
> > > > >> > > > We do appreciate you try out Tellurium new APIs and seems they
> > > > >> worked for
> > > > >> > > > most time. But
> > > > >> > > > Tellurium APIs are still experimental and please switch back
> > to
> > > > >> Selenium
> > > > >> > > > APIs if you run into
> > > > >> > > > any problems. Please keep trying the Tellurium new APIs and
> > > > >> reporting
> > > > >> > > > problems, which is
> > > > >> > > > the only way Tellurium Engine could be improved.
>
> > > > >> > > > As a rule of thumb, the commands in the format of
>
> > > > >> > > > useXXXX(boolean isUse)
>
> > > > >> > > > for example useTelluriumEngine(boolean isUse), are defined for
> > > > >> Groovy and
> > > > >> > > > Java base test cases.
>
> > > > >> > > > The counterparts of the same command is
>
> > > > >> > > > enableXXXX()
> > > > >> > > > disableXXXX()
>
> > > > >> > > > in DslContext.
>
> > > > >> > > > Hope this helps.
>
> > > > >> > > > Thanks,
>
> > > > >> > > > Jian
>
> > > > >> > > > On Wed, Sep 8, 2010 at 9:37 AM, Jade <[email protected]>
> > wrote:
> > > > >> > > > > Hi Jian,
>
> > > > >> > > > > Is there any documentation that specifies what the following
> > > > >> options
> > > > >> > > > > provide?
>
> > > > >> > > > > useTelluriumEngine(true) (not available in
> > > > >> TelluriumDataDrivenModule)
> > > > >> > > > > vs enableTelluriumEngine() (available in
> > > > >> TelluriumDataDrivenModule)
>
> > > > >> > > > > vs. useTelluriumApi(true)
>
> > > > >> > > > > My tests seem to work best when useTelluriumEngine(false)
> > and
> > > > >> > > > > useTelluriumApi(true) is set in the TelluriumDataDrivenTest
> > > > >> subclass
> > > > >> > > > > but I'm wondering what specific functionality that is
> > turning off
> > > > >> and
> > > > >> > > > > on for my tests?
>
> > > > >> > > > > Jade
>
> > > > >> > > > > On Sep 8, 8:00 am, Jade <[email protected]> wrote:
> > > > >> > > > > > In my groovy code of my data driven test (subclass of
> > > > >> > > > > > TelluriumDataDrivenModule), I have the call:
>
> > > > >> > > > > > validate "DspaceLoginForm"
>
> > > > >> > > > > > useTelluriumEngine(true)
> > > > >> > > > > > type
> > > > >> "DspaceLoginForm.LoginEmail",
> > > > >> > > email
> > > > >> > > > > > pause
> > > > >> VireoTestConfig.getPauseTime()
>
> > > > >> > > > > > which results in this exception:
>
> > > > >> > > > > > groovy.lang.MissingMethodException: No signature of
> > method:
>
> > org.tdl.vireo.webtest.datadriventests.module.DspaceLogonModule.useTelluriumEngine()
> > > > >> > > > > > is applicable for argument types: (java.lang.Boolean)
> > values:
> > > > >> [true]
> > > > >> > > > > > Possible solutions: useTelluriumApi(boolean)
>
> > > > >> > > > > > I'm using the latest jars as of Sept 7, 2010
>
> > > > >> > > > > > Jade
>
> > > > >> > > > > > On Sep 7, 7:12 pm, Jian Fang <[email protected]>
> > wrote:
>
> > > > >> > > > > > > useTelluriumEngine(isUse) actually calls couple APIs
> > under the
> > > > >> > > hood,
>
> >http://code.google.com/p/aost/wiki/UserGuide070TelluriumBasics#useTel.
> > > > >> > > > > ..
>
> > > > >> > > > > > > In 0.8.0, we may want to remove other options so that
> > user
> > > > >> only
> > > > >> > > uses
> > > > >> > > > > > > useTelluriumEngine(isUse) to change the framework
> > behavior. If
> > > > >> you
> > > > >> > > can
> > > > >> > > > > call
> > > > >> > > > > > > useTelluriumApi(), you should be able to call
> > > > >> > > useTelluriumEngine(isUse)
> > > > >> > > > > as
> > > > >> > > > > > > well, they are
> > > > >> > > > > > > all defined in the test case.
>
> > > > >> > > > > > > Thanks,
>
> > > > >> > > > > > > Jian
>
> > > > >> > > > > > > On Tue, Sep 7, 2010 at 5:17 PM, Jade <[email protected]>
> > > > >> wrote:
> > > > >> > > > > > > > Since the tests are data driven, all of the code that
> > > > >> manipulates
> > > > >> > > the
> > > > >> > > > > > > > html elements is in groovy. The only option is to set
> > > > >> > > > > > > > useTelluriumApi() to false before calling these lines
> > and
> > > > >> then to
> > > > >> > > > > true
> > > > >> > > > > > > > afterwards but that's not the same as setting
> > > > >> TelluriumEngine to
> > > > >> > > > > > > > false. I can set the TelluriumEngine to false in the
> > test
> > > > >> code
> > > > >> > > such
> > > > >> > > > > as
> > > > >> > > > > > > > public void testDataDriven() {
>
> > > > >> > > > > > > > // If you are not using Tellurium
> > Engine, you
> > > > >> > > don't
> > > > >> > > > > need to
> > > > >> > > > > > > > use
> > > > >> > > > > > > > cache.
> > > > >> > > > > > > > useTelluriumEngine(false);
>
> > > > >> > > > > > > > but then I can't turn it off only
>
> ...
>
> 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.