java - 方法 verifyTrue(boolean) 未定义类型

标签 java testing selenium testng

伙计们,

新手请多多关照!

我有一门课,我首先尝试确定“如果”文本 “虚构测试公司”存在于页面上的任何地方然后我想 单击并删除该公司“其他”我想添加一个新测试 公司..

我遇到的问题是以下行:

            if(verifyTrue(selenium.isTextPresent("Fictitious Test Company"))){;

编译器不断提示“方法 verifyTrue(boolean) 是 未定义类型 Delete_old_Or_Add_New_Company' */

你能告诉我哪里出错了吗?请具体说明我需要做什么来纠正这个问题。

这是我类(class)的全部代码: - 我正在使用 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);

        } 

最佳答案

编译器是正确的。 verifyTrue 方法在您的类中确实不存在。你的类(class)应该扩展 SeleneseTestCase ,其中定义了该方法。

关于java - 方法 verifyTrue(boolean) 未定义类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7487937/

相关文章:

java - Android Studio gradle buildConfigField 设置

javascript - 如何正确测试函数

c# - 使用 stub 和模拟的正确方法是什么?

testing - 任何可以测试 PowerBuilder 应用程序和 Web 应用程序的测试工具?

java - 是否有一种特定的方法可以从 java 代码调用特定场景,而不是使用 TestRunner 和标签?

java - Selenium:网页弹出/警报/通知消息的元素不可见异常

java - 异常(org.openqa.selenium.NoSuchWindowException): using Selenium WebDriver with Java in Internet Explorer

java - 安卓无法打开我的应用程序

java - 删除cookie的方法

java - jdbc 可以通过 SOCKS 代理连接到 Oracle 数据库吗?