代码之家  ›  专栏  ›  技术社区  ›  Adam Driscoll

硒批评

  •  16
  • Adam Driscoll  · 技术社区  · 16 年前

    我只是想听听那些经营硒的人的意见( http://selenium.openqa.org )我对瓦廷有很多经验,甚至为它写了一个录音套件。我让它生成了一些结构良好的代码,但仅仅由我来维护它,似乎我的公司都放弃了它。如果你运行硒,你有很多成功吗?我将使用.NET 3.5,Selenium和它一起工作吗?生成的代码是干净的还是只是所有交互的列表?( http://blogs.conchango.com/richardgriffin/archive/2006/11/14/Testing-Design-Pattern-for-using-WATiR_2F00_N.aspx )分布式测试套件的公平性如何?

    对系统的任何其他抱怨或赞美都将非常感谢!

    5 回复  |  直到 16 年前
        1
  •  26
  •   marcospereira    16 年前

    Selenium IDE

    Page Object Pattern Coding Dojo Floripa

    public class GoogleTest {
    
        private Selenium selenium;
    
        @Before
        public void setUp() throws Exception {
                selenium = new DefaultSelenium("localhost", 4444, "*firefox",
                                "http://www.google.com/webhp?hl=en");
                selenium.start();
        }
    
        @Test
        public void codingDojoShouldBeInFirstPageOfResults() {
                GoogleHomePage home = new GoogleHomePage(selenium);
                GoogleSearchResults searchResults = home.searchFor("coding dojo");
                String firstEntry = searchResults.getResult(0);
                assertEquals("Coding Dojo Wiki: FrontPage", firstEntry);
        }
    
        @After
        public void tearDown() throws Exception {
                selenium.stop();
        }
    
    }
    
    
    public class GoogleHomePage {
    
        private final Selenium selenium;
    
        public GoogleHomePage(Selenium selenium) {
                this.selenium = selenium;
                this.selenium.open("http://www.google.com/webhp?hl=en");
                if (!"Google".equals(selenium.getTitle())) {
                        throw new IllegalStateException("Not the Google Home Page");
                }
        }
    
        public GoogleSearchResults searchFor(String string) {
                selenium.type("q", string);
                selenium.click("btnG");
                selenium.waitForPageToLoad("5000");
                return new GoogleSearchResults(string, selenium);
        }
    }
    
    public class GoogleSearchResults {
    
        private final Selenium selenium;
    
        public GoogleSearchResults(String string, Selenium selenium) {
                this.selenium = selenium;
                if (!(string + " - Google Search").equals(selenium.getTitle())) {
                        throw new IllegalStateException(
                                        "This is not the Google Results Page");
                }
        }
    
        public String getResult(int i) {
                String nameXPath = "xpath=id('res')/div[1]/div[" + (i + 1) + "]/h2/a";
                return selenium.getText(nameXPath);
        }
    }
    

        3
  •  3
  •   Howard    16 年前

        4
  •  1
  •   Petteri H    16 年前

        5
  •  1
  •   Mark Erdmann    15 年前