0
我運行了以下數據驅動測試代碼,但得到以下錯誤:獲得log4j的錯誤,同時運行數據驅動測試代碼
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
誰能幫我解決這個問題,
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class DataDriven_Ex {
static WebElement searchbox;
public static void main(String[] args) {
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.amazon.in");
WebElement searchbox = driver.findElement(By.xpath("//*[@id='twotabsearchtextbox']"));
}
@Test
public void test() throws Exception {
File file = new File("F://Selenium excel//DataDriven.xlsx");
FileInputStream fs = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(fs);
XSSFSheet sh = wb.getSheet("Sheet1");
int rowcount = sh.getLastRowNum();
for (int i = 0; i<=rowcount;i++)
{
String keyword = sh.getRow(i).getCell(0).getStringCellValue();
searchbox.sendKeys(keyword);
searchbox.submit();
}
}
}
我該怎麼做。您能否詳細解釋我 – Priyanka
@Priyanka在測試方法開始時添加以下指令可能會解決您的問題:'org.apache.log4j.BasicConfigurator.configure();'。 –
它不工作....得到相同的錯誤。我需要做別的事嗎? – Priyanka