Нужна ваша помощь в кодировании Selenium webdriver с Java. < /p>
У меня есть сценарий, где я создаю имя курса и отправляю его в базу данных, а затем мне нужно искать курс по имени, который я его создал. Введите имя курса в текстовом поле (здесь я случайным образом генерирую строку, чтобы она не была жесткой, мне нужно получить именно то, что я напечатал здесь)
2. Храните напечатанное имя
3. В окне поиска введите это имя < /p>
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.generateRandomAlphaNumeric(10)); // Here I'm randomly 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
// . . .
< /code>
Кроме того, в основном методе я тоже объявил переменную. < /p>
public class TestCaseCreateCurriculum {
private Selenium selenium;
private WebDriver driver;
GenerateData genData;
public String curName;
// . . .
< /code>
Кто -нибудь может помочь мне исправить этот код?driver.findElement(By.id("Text1")).sendKeys(curName = "My Curriculum" + genData.generateRandomAlphaNumeric(10));
< /code>
и < /p>
driver.findElement(By.xpath("//div/input")).sendKeys(curName);
Подробнее здесь: https://stackoverflow.com/questions/234 ... river-usin
Как сохранить значение текстового поля и получить его позже - веб -драйвер Selenium с помощью Java ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение