Java 从Excel数据中获取文本并单击web元素Selenium单选按钮
两个测试单独运行正常,我需要帮助合并它们。Java 从Excel数据中获取文本并单击web元素Selenium单选按钮,java,selenium,selenium-webdriver,radio-button,apache-poi,Java,Selenium,Selenium Webdriver,Radio Button,Apache Poi,两个测试单独运行正常,我需要帮助合并它们。 我无法同时测试两者。 如果图纸单元读取为阳性,则应单击阳性单选按钮。 请帮我解决这个测试 java将从excel工作表中读取特定单元格。 java将对单选按钮运行测试。 数据的Excel文件 package testpoi; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import
我无法同时测试两者。
如果图纸单元读取为阳性,则应单击阳性单选按钮。 请帮我解决这个测试 java将从excel工作表中读取特定单元格。 java将对单选按钮运行测试。 数据的Excel文件
package testpoi;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class facebookradio {
public static void main(String[] args) throws Exception {
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.facebook.com");
WebElement male_radio_button=driver.findElement(By.id("u_0_a"));
male_radio_button.click();
WebElement female_radio_button=driver.findElement(By.id("u_0_9"));
female_radio_button.click();
java将从excel工作表中读取特定单元格
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//How to read excel files using Apache POI
public class ExcelRead33 {
public static void main (String [] args) throws IOException{
FileInputStream fis = new FileInputStream("C:/DDFREAD.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(1);
//Read specific row and column
Row row = sheet.getRow(2);
Cell cell = row.getCell(8);
//This will print data which I want to click
System.out.println(cell);
在学习Selenium之前,提高您的核心java技能。这是一个肮脏的代码[没有利用OOPs]你试图执行什么
FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "/src/october2018/Q52995381.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheet("Sheet1");
// Read specific row and column
Row row = sheet.getRow(2);
Cell cell = row.getCell(7);
// This will print data which I want to click
System.out.println(cell);
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/src/drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.facebook.com");
if (cell.toString().contentEquals("male")) {
WebElement male_radio_button = driver.findElement(By.xpath("//input[@value='2']"));
male_radio_button.click();
} else {
WebElement female_radio_button = driver.findElement(By.xpath("//input[@value='1']"));
female_radio_button.click();
}
我想你的意思是“无法”而不是“不可用”。请在原始帖子中显示你的尝试以及你的代码列表,以及你尝试时遇到的错误。