【发布时间】:2011-09-20 15:44:04
【问题描述】:
章节,
这里是新手,所以请温柔!
我有一门课,我首先尝试确定“如果”文本 页面上任何地方都存在“虚构的测试公司”,然后我想 单击并删除该公司“其他”我想添加一个新测试 公司..
我遇到的问题是以下行:
if(verifyTrue(selenium.isTextPresent("Fictitious Test Company"))){;
编译器不断抱怨“verifyTrue(boolean) 方法是 未定义类型 Delete_old_Or_Add_New_Company' */
你能告诉我哪里出错了吗?请具体说明我需要做什么来纠正问题。
这是我班级的全部代码: - 我正在使用 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);
}
【问题讨论】:
-
也许我只是疯了,但是为什么开头的花括号后面有一个分号?
-
欢迎您!尽管非常欢迎您在这里发帖,但我一直在将我们的 QA 人员(也在学习 selenium)转发到 sqa.stackexchange.com——但是 Selenium 是如此基于编程,我认为它在任何一个地方都有效..跨度>
-
考虑到他遇到的错误,我认为分号是他在将其格式化以发布到此处时发生的剪切和粘贴事故。
-
@Bill 感谢您的帮助!正如你所建议的,我已经省略了“verifyTrue”部分,错误似乎已经消失了。然而,在运行时,即使页面上存在文本“Fictitious Test company”,if 语句之后的部分也不会执行,而是直接进入 Else部分代码。你能解释一下为什么会这样吗?顺便说一句 - 感谢您将我指向 sqa.stackexchange.com。 :)
标签: java testing selenium testng