我是使用Selenium和Java进行自动化的新手。实际上,我正在测试基于学生表单测试的场景。现在问题我已经遇到了很多并尝试解决但是我失败了我想在输入字段中动态发送名字和姓氏,然后根据名字和姓氏过滤数据,但现在我想点击动态过滤数据同时想点击行上的元素请帮我弄清楚这个问题
System.setProperty("webdriver.chrome.driver","E:\\workspace\\chromeDriver\\chromeDriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("");
driver.findElement(By.id("login_username")).sendKeys("");
driver.findElement(By.id("login_password")).sendKeys("");
driver.findElement(By.xpath("/html/body/div[3]/div[3]/div/button[1]")).click();
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='lsmainmenu']/li[2]/a")).click();
driver.findElement(By.xpath(".//*[@id='lsmainmenu']/li[2]/ul/li[3]/a")).click();
Thread.sleep(2000);
WebElement x=driver.findElement(By.id("personListFilterForm_name"));
x.sendKeys("Bern_name Fuss_name");
Thread.sleep(200);
driver.findElement(By.xpath(".//*[@id='student-list-filters']/div/table/tbody/tr[2]/td[2]/div[1]/table/tbody/tr/td[5]/input")).click();
Thread.sleep(3000);
driver.findElement(By.id("i wan this section is click dynmacilly according to firsname and lastename ")).click();
Thread.sleep(1000);
答案 0 :(得分:0)
尝试此操作以单击给定的firstname \ lastname。假设你已经知道名字\ lastname
driver.findElement(By.xpath("\\*[contains(text(),'Firstname')]")).click();