Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Xebium contextmenu #115

Open
tombeuckelaere opened this issue Mar 17, 2014 · 6 comments
Open

Xebium contextmenu #115

tombeuckelaere opened this issue Mar 17, 2014 · 6 comments

Comments

@tombeuckelaere
Copy link

Related to this problem (#57) I still can't open the context menu with xebium.

jguglielmi stated this can be solved by writing a custom fixture. However I don't have the knowledge to do this.

Can you provide me instructions so I can fix this?
We are in urgent need for a working context menu command.

@tombeuckelaere
Copy link
Author

With thanks to jguglielmi I have a custom fixture in SeleniumDriverFixture.java.
However: if the commands throws an error or succeeds it will always be green in fitnesse.
How can I make sure I get a failed test when the command doesn't succeed and throws an error as viewed in the logging?

Just throwing ex in the catch context doesn't work. Maven won't build that.

private String executeCommand(final ExtendedSeleniumCommand command, final String[] values, long delay) {
        ....                
        // --START [17/03/2014 - tombeuckelaere]--      
        if ("contextMenu".equals(command.getSeleniumCommand())) {
            try {
                WebElement webElement = getWebDriver().findElement(By.xpath(values[0]));
                new Actions(getWebDriver()).contextClick(webElement).perform();
                LOG.info("Performing | contextMenu | " + values[0] + " | " );               
            }           
            catch (Exception e) {
                LOG.error("contextMenu command interrupted", e);                                                        
            }
            return null;
        }
                // --END [17/03/2014 - tombeuckelaere]--
               ....
}

@tombeuckelaere
Copy link
Author

Ok, after looking around for a day (and 5 minutes after posting the above), the code below is the working version of the contextmenu.

Concrete basic usage in fitnesse:
|ensure|do|contextMenu|on|your xpath expresion here|
It will turn green (success) when it opened the contextmenu.
It will turn red (failure) when a seleniumexception occures (for ex. element not found).

Maybe this command can be added to the standard package of xebium?

Update 20/03/2014
Now the id of the element which the contextmenu has been clicked on will be returned. This is useful when using xpath expression with text lookup (when id is unknown)

Contextmenu and you wish to get the clicked elements id
!|script|
|$elementid=|is|contextMenu|on|//table/tbody/tr/td/span[contains(text(),'textlookupstring')]|

Contextmenu and you don't wish to get the clicked elements id
!|script|
|ensure |do|contextMenu|on|//table/tbody/tr/td/span[contains(text(),'textlookupstring')]|

// --START [17/03/2014 - tombeuckelaere]--      
        if ("contextMenu".equals(command.getSeleniumCommand())) {
            try {
                WebElement webElement = getWebDriver().findElement(By.xpath(values[0]));
                new Actions(getWebDriver()).contextClick(webElement).perform();
                LOG.info("Performing | contextMenu | " + values[0] + " | " );   
                output= webElement.getAttribute("id");
                LOG.info("Performing | contextMenu | " + values[0] + " | element id is " + output );    
            }           
             catch (final SeleniumException e) {
                output = "Execution of command contextMenu failed: " + e.getMessage();
                LOG.error(output);                                                                      
             }          

             return output;
        }
        // --END [17/03/2014 - tombeuckelaere]--

@jguglielmi
Copy link

Tom, the contextMenu is directly in seleniumdriverfixture.java and not a custom fixture. You can view my pull request...#122

You can add css, id, or any other implementation you'd like. We(@ejakubowski and I) are preferable to xpath. We trained our testers in it because we also use SynthUse for thick client testing. Users of our own medicine. :)

@jguglielmi
Copy link

So can you close this?

@jguglielmi
Copy link

This is good stuff by the way Tom. Can you fork OASIS and submit this over as a pull request? Also do the same for Xebium. I don't want to take credit for your efforts. http://github.com/jguglielmi/OASIS

@alexanderrosenfeldfmr
Copy link
Contributor

I have made a pull request in relation to this issue here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants