Selenium脚本问题" 0测试类在包"在跑步的时候

时间:2016-03-01 16:29:40

标签: selenium selenium-webdriver automation

我是Java和Selenium的新手,不知道我的下面代码有什么问题

    public class SmokeTest{

    static WebDriver driver;
    ArrayList<String> testData = null;

    public void setUp() throws Exception {
        Date d = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("MMddyyHHmmss");

    }


    public ArrayList read() throws ParserConfigurationException, IOException, SAXException {

        testData = new ArrayList<>();
  //     File fXmlFile = new File("./blocks-automation/ws/src//Blocks.xml");
        File fXmlFile = new File("C:/Javaseleniumworld/Blocks.xml");
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(fXmlFile);
        doc.getDocumentElement().normalize();
//        System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
        NodeList nList = doc.getElementsByTagName("blocks");
        System.out.println("----------------------------");
        for (int temp = 0; temp < nList.getLength(); temp++) {
            Node nNode = nList.item(temp);
            System.out.println("\nCurrent Element :" + nNode.getNodeName());

            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) nNode;
                NodeList childEls = eElement.getElementsByTagName("*");
                for (int i = 0; i < childEls.getLength(); i++) {
                    Element cElement = (Element) childEls.item(i);
                    testData.add(cElement.getTextContent());
                }
            }
            System.out.println("array" + testData);
        }
        return testData;
    }


    public void main() throws IOException, SAXException, ParserConfigurationException {

        driver = new FirefoxDriver();
        this.read();

        driver.get(testData.get(0));
        driver.quit();
    }


}

我不确定如何解决这个问题。我尝试在这里移动代码,但仍然不知道如何处理这个问题。任何帮助,将不胜感激。

0 个答案:

没有答案