“无法获取”;“英语格言”;selenium中wikipedia.com表格中的文本
在wikipedia.com网站上,当我搜索安大学时,在右边的表格中,我找不到文本“英语座右铭” 我有一个selenium代码“无法获取”;“英语格言”;selenium中wikipedia.com表格中的文本,selenium,selenium-webdriver,Selenium,Selenium Webdriver,在wikipedia.com网站上,当我搜索安大学时,在右边的表格中,我找不到文本“英语座右铭” 我有一个selenium代码 WebDriver driver=new FirefoxDriver(); driver.get("http:\\wikipedia.org"); WebElement lin=driver.findElement(By.xpath("//*[@id='js-link-box-en']/small")); lin.click(); driver.findEle
WebDriver driver=new FirefoxDriver();
driver.get("http:\\wikipedia.org");
WebElement lin=driver.findElement(By.xpath("//*[@id='js-link-box-en']/small"));
lin.click();
driver.findElement(By.xpath("//*[@id='searchInput']")).sendKeys("Anna University",Keys.ENTER);
List<WebElement> tablecollection= driver.findElements(By.xpath("//table[@class='infobox vcard']"));
System.out.println(tablecollection.size());
WebDriver=newfirefoxdriver();
获取(http:\\wikipedia.org);
WebElement lin=driver.findElement(By.xpath(“/*[@id='js-link-box-en']/small”);
林。点击();
driver.findelelement(By.xpath(“/*[@id='searchInput'])).sendKeys(“安娜大学”,Keys.ENTER);
List tablecollection=driver.findElements(By.xpath(//table[@class='infobox vcard']);
System.out.println(tablecollection.size());
最后一行显示输出中的0我回答了您的问题 打印时
System.out.println(tablecollection.size());
它返回2,我也在Eclipse中运行了该脚本
要打印“英文座右铭”,首先必须找到它,然后使用getText()
你可以打印文本
driver.get("http://wikipedia.org");
WebElement lin=driver.findElement(By.xpath("//*[@id='js-link-box-en']/small"));
lin.click();
driver.findElement(By.xpath("//*[@id='searchInput']")).sendKeys("Anna University",Keys.ENTER);
List tablecollection= driver.findElements(By.xpath("//table[@class='infobox vcard']"));
System.out.println(tablecollection.size());
WebElement Motttoele=driver.findElement(By.xpath("//div[contains(text(),'Motto')]"));
System.out.println(Motttoele.getText());
当我跑步时,它返回2