2

I've got problem I can't deal with. I've tried to search answer in google, tried few things but it doesn't work any way.

Here is the problem:

I'm testing a log in page, where I type in login, password and click "login" button. Everything is OK, I'm logging to the page... But before log in (after click "login" button) there should appear a prompt with some info and "OK" button, the prompt is onclick() event of "login" button. I have no idea why the prompt doesn't show up, and I really need this prompt (I have similar problem with prompt "Do you want to save changes" which also doesn't appear - I assumed that selenium.click(..,..) and webelement.click() somehow bypass onclick() events. Do you have any idea what to do to have onclick() events working properly? I'm using IE (I have to) and selenium webdriver.

Ps.:if I do same actions "manually" the prompts do appear so I don't think that its a mistake in javascript.

Ps2.: Help me please I'm trying to fix it for a 5 h...:(

button code:

<input id="loginForm:loginCmdTest" type="submit" onclick="showAlertAndSubmitForm    ();clear_loginForm();" value="Login" name="loginForm:loginCmdTest">

java code:

selenium.type("id=loginForm:login", login);
selenium.type("id=loginForm:pass", pass);
selenium.click("id=loginForm:loginCmdTest");

Ps.3: ANYONE?? Any idea?

4

1 回答 1

4

简单的猜测:您使用的是旧的、已弃用的 Selenium RC。如果将其转移到 webdriver 方法会发生什么?

示例代码:

WebDriver driver = new FirefoxDriver();
driver.get("http://your-test-site.com");
driver.findElement(By.id("loginForm:login")).sendKeys("login");
driver.findElement(By.id("loginForm:pass")).sendKeys("pass");
driver.findElement(By.id("loginForm:loginCmdTest").click();
于 2013-08-02T13:02:30.127 回答