【问题标题】:I am facing issue while printing the size of list in eclipse for selenium [closed]我在 eclipse 中打印硒的列表大小时遇到​​问题[关闭]
【发布时间】:2018-09-03 22:37:19
【问题描述】:

我在打印列表大小时遇到​​问题:

System.out.println("no of list", +list.size());

错误是: "the method println(int)" in the type printstream is not applicable for the arguments(string, int)

这是我的代码:

package newpackage;


import java.util.List;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.ie.InternetExplorerDriver;

public class TagNme_Locator {

public static void main(String[] args) {
 System.setProperty("webdriver.ie.driver", "C:\\Program [enter image description here][1]Files\\selenium\\IEDriver\\IEDriverServer.exe");
 WebDriver driver= new InternetExplorerDriver();
 driver.get("https://www.facebook.com/");
 List <WebElement> list= driver.findElements(By.tagName("div"));    
 System.out.println("no of list", +list.size());
 for(int i = 0; i < list.size(); i++){
     System.out.println(list.get(i).getText());
 }
}
}

【问题讨论】:

  • 删除,
  • 逗号表示您尝试输入两个参数,但它只接受一个。如上所述,删除逗号或在引号内移动。
  • 谢谢.. 我是 selenium 和 java 的新手。感谢您的帮助。

标签: java eclipse selenium


【解决方案1】:

正如 cmets 中所述,您使用的是逗号而不是所需的串联运算符,即 Java 中的 +。我不确定逗号是否是有意的,基于+list.size(),但你永远不知道。

错误意味着很多如果你知道如何解释它们,这意味着你不能使用Stringint类型的两个参数以及为参数定义的方法int.

【讨论】:

  • 谢谢。它现在正在工作
猜你喜欢
  • 2022-01-20
  • 1970-01-01
  • 1970-01-01
  • 2018-01-24
  • 2022-07-11
  • 1970-01-01
  • 2022-01-21
  • 2021-12-13
  • 1970-01-01
相关资源
最近更新 更多