Best keyword to tab off an element

I have a drop down combo element that I need to focus on and tab off in order to fire a validation message. I cannot use Press Keys or Click Element as it will invoke the list and I cannot use Mouse Over since the only argument is location. Does anyone have suggestions to handle this scenario?

Example:
image

1 Like

I also want some TAB-ing on my website and have problems with using press keys

My first question is how are you achieving this manually?

Once you know this you can plan a possible approach that can simulate the same manual sequence.

Dave.

try some javascript, perhaps that could help there

I tab to the element from a different element and then tab off the element. But I do not wish to use that as my method. The reason is because I want to reuse the same user defined keyword in other tests and the tab order will be different.

Is there a keyword that allows the use of tabbing without using Press Keys or Click Element?

OK so what I suggest is

  • first navigate to the element before the “drop down combo element” in the tab order with a click or other action that gets you there.
  • Use Press Keys with a locator of None and the TAB key. (this sends the Tab key to the browser window not the element, hopefully this will simulate what you are doing manually)
  • Use Press Keys with a locator of None and the TAB key again to navigate off the “drop down combo element”
  • verify the error message

You might also want to add a Element Should Be Focused step between the Press Keys steps to verify you went to the right field (in case the tab order changed in some future release)

Dave.

This does solve the noted problem - thanks, but it exposes a more complex issue that I am trying to resolve.

The field in question “Organization” occurs in several different forms within the application. My goal was to setup a single kwarg within the test that can be repeated for every form. The issue is the field is not placed in the same place in all of the different forms.

This appears to leave me with two choices: Create a kwarg and unique keywords for each form to handle the Press Keys (NONE TAB) or find a keyword that allows me to have focus on the field (drop down combo) without invoking the list. The latter is what I was originally trying to handle.

Example that I am trying to avoid:
Validate Organization is Required Form A
Validate Organization is Required Form B
Validate Organization is Required Form C

@lslackware1 said to try some javascript, but I am not familiar with java so have not found a proper solution. If anyone has a java suggestion please advise.

I have tried the following but now how to tab off without invoking the list:
Execute Javascript document.getElementById${ORGANIZATION}.focus();

Maybe try a keyword for validating the field that takes an argument for the previous field?

Something like:

Validate Organization is Required
    [Arguments]    ${prev_fld}
    Click    ${prev_fld}
    Press Keys    None    TAB
    Press Keys    None    TAB
    # validate error

Then in you test case for Form A

    Validate Organization is Required    //locator/for/prev/fielda

Then in you test case for Form B

    Validate Organization is Required    css: fieldb

etc