为什么这段代码会从我项目中随机的其他代码中抛出输出?我怎样才能解决这个问题? [英] Why is this code throwing an output from a random other code in my project? How can I fix this?

查看:109
本文介绍了为什么这段代码会从我项目中随机的其他代码中抛出输出?我怎样才能解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,我可能在代码中弄乱了一些东西。但这里有什么问题?我正在尝试为我必须测试的主页中的元素创建对象。

I am new to Java and I might have messed up something in the code. But what is wrong here? I am trying to create objects for the elements in the home page which I have to test.

   package pageObjects;

      import org.openqa.selenium.By;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebElement;

public class HomePage {

private static WebElement element;

public static void main(String args[], WebDriver driver){

    HomePage hp = new HomePage();
    hp.SignInButton(driver);
    hp.ImageButton(driver);
    System.out.println("Yup");
}

public WebElement SignInButton(WebDriver driver){

    element = driver.findElement(By.linkText("Sign In"));
    System.out.println("Yeua");
    return element;

}

public WebElement ImageButton(WebDriver driver){

    return element = driver.findElement(By.linkText("Images"));

}

  }


推荐答案

根据您使用的IDE,您必须检查运行配置并查看正在执行的IDE。

Depending on the IDE you are using, you have to check the run configuration and see, which one is being executed.

如果您不这样做有一个有效的 main()开始,大多数IDE将使用有效的 main()

If you do not have a valid main() to start with, most IDEs will execute the last file that you started with a valid main().

你的 main()有多个参数 public static void main( String args [],WebDriver驱动程序)

删除 WebDriver驱动程序

这篇关于为什么这段代码会从我项目中随机的其他代码中抛出输出?我怎样才能解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆