首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在selenium ide中处理javascript

在selenium ide中处理javascript
EN

Stack Overflow用户
提问于 2013-03-28 13:23:00
回答 2查看 1.4K关注 0票数 0

下面是我点击提交按钮失败的例子:

代码语言:javascript
复制
package demo;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class leadtest 
        {
    private Selenium selenium;
    private SeleniumServer server;

    @Before
    public void setUp() throws Exception 
                {
        server = new SeleniumServer();
        server.start();
        selenium = new DefaultSelenium("localhost", 4444, "*firefox",
            "http://www.careerfundas.com/");
        selenium.start();
            }

    @Test
   public void testLeadtest() throws Exception
                {
        selenium.open("/");
        selenium.click("id=wrapper");
        selenium.click("css=a.active-home > span");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=wrapper");
        selenium.click("css=li");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=confused_name");
        selenium.type("id=confused_name", "Shalini test");
        selenium.type("id=confused_email", "Shalinitest@test.com");
        selenium.type("id=confused_phoneno", "9090909090");
        selenium.select("id=conf_course", "label=Shipping and Logistics");
        selenium.click("link=Ask Expert");
        assertEquals(
            "Thank You ! Someone from Career Fundas experts panel will    contact you shortly.", selenium.getAlert());


            }



    @After
    public void tearDown() throws Exception 
       {
        selenium.stop();
   }

      }  

注意:下面是我试图运行上面的java脚本时得到的错误。

代码语言:javascript
复制
com.thoughtworks.selenium.SeleniumException: ERROR: There were no alerts
at com.thoughtworks.selenium.HttpCommandProcessor.
throwAssertionFailureExceptionOrError (HttpCommandProcessor.java:112)
EN

回答 2

Stack Overflow用户

发布于 2013-03-28 13:31:38

  1. 在执行geralert之前,您可以尝试使用selenium.setSpeed("5000")设置速度。
  2. 也许它并不警觉。也许这就是确认。您是否尝试过selenium.getConfirmation();

Here是关于它的更多信息。

票数 0
EN

Stack Overflow用户

发布于 2013-04-01 18:34:51

代码语言:javascript
复制
selenium.click("link=Ask Expert");
Thread.sleep(5000);
assertEquals("Thank You ! Someone from Career Fundas experts panel will contact you shortly.", selenium.getAlert());

使用这段代码,它在我这一端工作

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15674798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档