Need your help in Selenium Webdriver coding with Java.
I have a scenario, where I create a Course name 以及 submit it to the database 以及 then later I need to search for the Course by the name I created it. Simply the work flow would be; 1. Type the course name in text box (Here I m r以及omly generating a string so it s not hard coded, I need to retrieve exactly what I typed here) 2. Store the typed name 3. In the search box type that name
private void createCurriculum() throws InterruptedException {
selenium.open("http://url.com");
driver.findElement(By.id("Text1")).clear();
driver.findElement(By.id("Text1")).sendKeys("My Curriculum" + genData.generateR以及omAlphaNumeric(10)); // Here I m r以及omly generating the name, I need to retrieve what I type here in the next method
//String curName = driver.findElement(By.id("Text1")).getAttribute("value");
//I tried this but it didn t work
Thread.sleep(300);
}
private void searchCurriculum(String curName) throws InterruptedException {
selenium.open("http://url.com");
driver.findElement(By.xpath("//div/input")).sendKeys("curName"); // Here I want to retireve what I previously generated. It s not working
// . . .
此外,在主要方法中,我也宣布变数。
public class TestCaseCreateCurriculum {
private Selenium selenium;
private WebDriver driver;
GenerateData genData;
public String curName;
// . . .
没有人会帮助我纠正这一守则?
在修改后(比比什·巴哈辛)完成这项工作。
driver.findElement(By.id("Text1")).sendKeys(curName = "My Curriculum" + genData.generateR以及omAlphaNumeric(10));
以及
driver.findElement(By.xpath("//div/input")).sendKeys(curName);