Tag: seleniumselenium

尝试将webtable导出为ex​​cel时出现无效的select器错误

错误是:给定的select器表[class ='stats_table data_grid'] tbody tr [0] td [0]无效或不导致WebElement。 发生以下错误:InvalidSelectorError:指定了无效或非法的select器 观察:我检查了没有[“+ r +”]和[“+ c +”]的cssSelector,它是有效的。 所以错误来自于加“[+ r +”]和[“+ c +”],我无法缓解。 我的总体目标是从mlb.com/stats的webtable中获取数据,并将其input到Excel表格中。 几乎99%的代码工作正常,除了无效的cssSelector问题。 我的代码是: package automate; import java.io.FileOutputStream; import java.io.IOException; import java.util.List; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class MLBtoXL { static WebDriver driver = new […]

如何从Web上的边桌数据打印列标题与WebDriver优秀

问题下面的代码允许我打印列标题或将网页表格数据打印到CSV文件,具体取决于我是select“th”还是“td”标签,但不是同时select。 我的问题如何在CSV输出中同时打印csv'th'和'td'文本? 代码我已经尝试了我的代码的2个版本,但结果是相同的。所附的两个版本。 代码版本1 public class WebToCSV { static WebDriver driver = new FirefoxDriver(); public static void main(String[] args) throws Throwable { //driver.navigate().to("http://goo.gl/El1PIV"); driver.navigate().to("http://www.bloomberg.com/markets/stocks/futures"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebElement table = driver.findElement(By.cssSelector ("div[class='data-tables first']")); List<WebElement> irow = table.findElements (By.cssSelector("div[class='data-tables first'] tr")); System.out.println("No. of rows in the table are: " + irow.size()); // Create excel workbook and […]

使用Selenium RC,Excel(数据驱动)和SeleniumException

我现在正在开发一个自动化项目,在特定的网站上创build一个帐户。 有不同的规则需要检查。 需要有一组数据,其中缺less一些必填字段,用于在帐户上创build的电子邮件地址已经在系统上使用,最后一组是可以创build帐户的地方。 该过程的一般stream程是: 运行SeleniumRC 从ExcelFile获取数据 Excel数据由不同的集合组成。 设置A:缺less所需的Fille设置B:电子邮件地址已被使用设置B:完整/正确的数据 去网站。 input所有数据。 如果设置为A: Then creation will not process. It will provide output: Row Number – Error 如果设置B: Then creation will not process. It will provide output: Row Number – Error 如果设置C: It will create account. 提供屏幕截图盎司login 返回到步骤2,直到Excel文件中find的所有行都被完全检查。 输出将被放置在另一个Excel文件中 我能够运行的过程,但是,如果我在Excel文件中的每个条目使用一个标志。 这确实破坏了检查创build过程的预期目的。 我的selenium命令是这样的: public void test_CreateAccount() throws Exception { […]

使用Apache POI-Selenium Web驱动程序将dynamicWeb元素写入XLSX

您好我正在Selenium Webdriver上工作,我有一个下拉的网站,并select下拉值,然后点击一个button加载整个页面。 一旦页面加载,然后必须使用xpath从网页中find文本。 我想将下拉文本写入到xlx文件中,并且我想将文本(从xpath中find)写入xlx。 这两个值都是dynamic的。 如何开始,任何代码可以帮助我。 没有使用maven和selenium我想要写入数据到excel文件下面是我想写入excel文件的元素的屏幕截图 我已经写下来获取下拉值和xpath文本 – 要将StockScrip和Pattern写入excel文件 import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.WebDriverWait; import ExcelData.BullishBearishExcelFile; public class Driver { public static WebDriver driver; public static void main(String[] args) { BullishBearishExcelFile data = new BullishBearishExcelFile(); driver= new […]