English 中文(简体)
如何储存案文的外地价值,然后检索——使用 Java的Selenium网络司机
原标题:How to store a text field value and retrieve it later - Selenium Web Driver Using Java

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);
问题回答

你可以做一些事情:

String course = "My Curriculum" + genData.generateRandomAlphaNumeric(10);
driver.findElement(By.id("Text1")).sendKeys(course); 

之后,你可以使用《刑法》中任何地点储存的变数。

如果你不能解决你的问题,你可以把价值按类别储存在你想要恢复时。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签