0

Selenium WebDriver

asked 2013-08-22 11:41:07 +0800

sulaiman gravatar image sulaiman
0 1

updated 2013-08-22 11:42:19 +0800

Hi, I have web application and its implemented using Zkoss, the question is: Can I test it using Selenium WebDriver (recording the objects in the interface)?

Thanks..

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2013-08-22 15:58:43 +0800

terrytornado gravatar image terrytornado flag of Germany
9373 3 7 16
http://www.oxitec.de/

updated 2013-08-22 16:05:28 +0800

<button id="btnOK" class="btnOK_Selenium" label="OK"/>

you can have access in Selenium to the button by using it's class name. If you have already using the class name for a css modification you can add an additionally class name for selenium tests. <.. class="MyButtonCSS btnOK_Selenium" ../>

@FindBy(classname = "btnOK_Selenium")
private WebElement btnOK_Selenium;

/**
* Clicks the OK buttun.
*/
public void clickOKBtn() {
  $(this.btnOK_Selenium).click();
}

best Stephan

link publish delete flag offensive edit
0

answered 2014-02-25 14:40:37 +0800

TomHunter gravatar image TomHunter
21 2

updated 2014-02-25 14:41:45 +0800

I have successfully written a Selenium 2 (WebDriver) test against a ZK application. You will face two problems:

1.) You need to implement a ConsistentIDGenerator. 2.) Selenium 2 (WebDriver) does not offer a way to wait for a component to load. So, you end up putting in waits. For that reason, it might be a better idea to use Selenium 1 (RC).

3.) In lieu of the consistent Id generator, you can use things like class names to find components.

Please look at the example of the ConsistenIdGenerator.java class.

package mydomain;

import java.util.concurrent.atomic.AtomicInteger;

import javax.servlet.http.HttpServletResponse;

import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Desktop; import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.metainfo.ComponentInfo; import org.zkoss.zk.ui.sys.IdGenerator;

public class ConsistentIdGenerator implements IdGenerator {
private static final String ATTRIBUTEGENERATEDID = "generatedId";
private static final String HEADERDESKTOP = "Desktop"; private static final String ZKDESKTOPPREFIX = "zkdt"; private static final String ZKPAGEPREFIX = "zkpage"; private static final String ZKCOMPONENTPREFIX = "zkcomp_"; private static AtomicInteger desktopCounter = new AtomicInteger(); private static AtomicInteger pageCounter = new AtomicInteger();

@Override
public String nextComponentUuid(Desktop desktop, Component comp, ComponentInfo info) 
{
    if (!desktop.hasAttribute(ATTRIBUTE_GENERATED_ID)) 
    {
        desktop.setAttribute(ATTRIBUTE_GENERATED_ID, new AtomicInteger());
    }

    AtomicInteger componentCounter = (AtomicInteger) desktop.getAttribute(ATTRIBUTE_GENERATED_ID);
    return formatId(ZK_COMPONENT_PREFIX, componentCounter);
}

@Override
public String nextPageUuid(Page page) 
{
    return formatId(ZK_PAGE_PREFIX, pageCounter);
}

@Override
public String nextDesktopId(Desktop desktop) 
{
    String dtid = formatId(ZK_DESKTOP_PREFIX, desktopCounter);
    HttpServletResponse response = (HttpServletResponse) desktop.getExecution().getNativeResponse();
    response.addHeader(HEADER_DESKTOP, dtid);
    return dtid;
}

private String formatId(String prefix, AtomicInteger counter) 
{
    return prefix + Integer.toHexString(counter.getAndIncrement());
}

}

link publish delete flag offensive edit
0

answered 2014-03-30 07:19:54 +0800

Naif92 gravatar image Naif92
1

Would you please give us an example of the selenium testing code in web driver ? ( java)

because I don't know how to use the class " nextComponentUuid " in my test code !

link publish delete flag offensive edit
0

answered 2014-03-30 07:20:32 +0800

Naif92 gravatar image Naif92
1

Would you please give us an example of the selenium testing code in web driver ? ( java)

because I don't know how to use the class " nextComponentUuid " in my test code !

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-08-22 11:41:07 +0800

Seen: 47 times

Last updated: Dec 05