伙计们,
我是新手,所以请温柔点!
我有一个类,我首先尝试确定‘如果’文本‘虚构的测试公司’存在于页面上,然后我想单击并删除该公司‘否则’我想添加一个新的测试公司。
我的问题是以下几行:
if(verifyTrue(selenium.isTextPresent("Fictitious Test Company"))){;编译器总是抱怨‘未为类型Delete_old_Or_Add_New_Company定义方法verifyTrue(boolean)’*/
你能告诉我我哪里错了吗?请具体说明我需要做些什么来纠正这个问题。
下面是我的类的全部代码:-我使用xml在Eclipse中运行我的测试套件
package Realtime;
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
public class Delete_old_Or_Add_New_Company {
private Selenium selenium;
public static SeleneseTestBase SV = new
SeleneseTestBase();
@BeforeClass
@Parameters ({"url","browser","speed"})
public void startSelenium(String Site_URL, String Browser, String
Speed) {
selenium = new DefaultSelenium("localhost", 4444, Browser, Site_URL);
selenium.start();
selenium.setSpeed(Speed);
}
@AfterClass(alwaysRun=true)
public void stopSelenium() {
this.selenium.stop();
}
@Test
public void DeletOldOrAddNewCompany() throws Exception {
Login_Logout NewObject=new Login_Logout();
selenium.getEval("selenium.browserbot.setShouldHighlightElement(true)");
NewObject.Login(selenium);
selenium.waitForPageToLoad("5000");
selenium.click("//table[@id='maincontent']/tbody/tr/td[3]/table[2]/
tbody/tr[3]/td[5]/strong");
selenium.waitForPageToLoad("5000");
selenium.click("link=Companies");
selenium.waitForPageToLoad("5000");
selenium.click("//input[@value='Search for Companies']");
selenium.waitForPageToLoad("5000");
selenium.type("//input[@name=\"companyname\"]", "Fictitious Test
Company");
selenium.click("//input[@name=\"submitbutton\"]");
if(verifyTrue(selenium.isTextPresent("Fictitious Test Company"))){; /
* It is at this line the compiler complains that the 'The method
verifyTrue(boolean) is undefined for the type
Delete_old_Or_Add_New_Company' */
selenium.waitForPageToLoad("5000");
selenium.click("css=td.tablelastrownew");
selenium.waitForPageToLoad("5000");
selenium.click("//input[@value='Delete Company']");
assertTrue(selenium.getConfirmation().matches("^Note: This action
will delete all the companies accounts, branches, users and their
accounts\n\nAre you sure you wish to delete this company[\\s\\S]$"));
}
else {
selenium.click("//input[@value='Companies Admin Home']");
selenium.waitForPageToLoad("5000");
selenium.click("//input[@value='New Company']");
selenium.waitForPageToLoad("5000");
selenium.type("name=companyname", "Fictitious Test Company");
selenium.type("name=postcode", "SW17 8DY");
selenium.type("name=expirepasswordsindays", "1000");
selenium.click("css=input[name=\"submitbutton\"]");
selenium.waitForPageToLoad("5000");
SV.verifyTrue(selenium.isTextPresent("Fictitious Test Company"));
}
NewObject.Logout(selenium);
} 发布于 2011-09-21 09:04:37
您已经创建了SeleneseTestBase实例SV。
你应该调用"SV.verifyTrue“。或者,扩展SeleneseTestBase。
*您已经使用了这种方式。(else语句最后一行。)
SV.verifyTrue(selenium.isTextPresent("Fictitious Test Company")); *在Selenium 2.0中,SeleneseTestCase是不推荐使用的类。http://selenium.googlecode.com/svn/trunk/docs/api/java/com/thoughtworks/selenium/package-summary.html
发布于 2011-09-20 23:50:50
编译器是正确的。verifyTrue方法确实不存在于您的类中。您的类应该扩展SeleneseTestCase,该方法就是在这里定义的。
发布于 2011-09-20 23:47:41
Java告诉你verifyTrue是独立的,它不返回值,所以它不需要if语句。
如果参数为false,则测试将失败,并且测试将在此处停止。
我认为在这种情况下,您想要的是省略"verifyTrue“部分,只将其中的内容传递给if。
https://stackoverflow.com/questions/7487937
复制相似问题