Selenium 硒脚本问题“;在“包”中找到0个测试类;跑步时
我是Java和Selenium新手,不知道下面的代码有什么问题Selenium 硒脚本问题“;在“包”中找到0个测试类;跑步时,selenium,selenium-webdriver,automation,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
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();
}
}
公共类烟雾测试{
静态网络驱动程序;
ArrayList testData=null;
public void setUp()引发异常{
日期d=新日期();
SimpleDataFormat dateFormat=新的SimpleDataFormat(“MMddyyHHmmss”);
}
public ArrayList read()抛出ParserConfiguration异常、IOException、SAXException{
testData=newarraylist();
//File fXmlFile=新文件(“./blocks automation/ws/src//blocks.xml”);
File fXmlFile=新文件(“C:/Javaseleniumworld/Blocks.xml”);
DocumentBuilderFactory dbFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder=dbFactory.newDocumentBuilder();
documentdoc=dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
//System.out.println(“根元素:+doc.getDocumentElement().getNodeName());
NodeList nList=doc.getElementsByTagName(“块”);
System.out.println(“-------------------------------”;
对于(int-temp=0;temp
我不知道如何解决这个问题。我尝试在这里移动代码,但仍然不确定如何处理这个问题。任何帮助都将不胜感激 “我不熟悉Java和Selenium”。。。也许花点时间在文档上会有所帮助?我们不能教你Java。为了得到实际的帮助,你必须提供一份书面报告。@SiKing我一直在花时间阅读文档,没有必要重新措辞我的文本。我不是要你教我Java,我只是需要一些指导。问题是你的问题包含的信息太少,无法回答。请发布stacktrace(或确切的错误消息),删除代码中不相关的部分(但确保错误保持不变),并为问题添加一些基本上下文-您是否尝试将其作为JUnit/TestNG测试运行(在这种情况下,您缺少
@test
注释等),或者只是执行main方法?主要目标是什么,应该发生什么?谢谢我添加了@Test,主要问题是项目结构中的依赖项和jar文件。我添加了几个依赖项,它已经开始工作了。再次感谢你的帮助!