Save Textfiel text to a variable and insert into a field using Selenium driver

Asked

Viewed 687 times

1

I need to take data from a Textfiel (letters and number) and then insert it into a field using Selenium.

//Classe1 para pegar texto
String guardarPlaca;
    @FXML
    public void inserirDados(ActionEvent event) throws Exception {
        guardarPlaca = fieldPlaca.getText();
//pega o valor dele, e armazena na variável guardarplaca
        System.out.println(guardarPlaca);

    }


//Classe 2 para inserir em em campo usando Selenium
    Classe1 guardarPlaca = new Classe1();        
    driver.findElement(By.id("placa")).getAttribute("value");
    WebElement placa = driver.findElement(By.id("placa"));// localiza campo
    placa.clear();
    placa.sendKeys(String.valueOf(guardarPlaca));
  • What error is it making? When you declare the fieldPlate field its statement is preceded by @FXML?

  • I was able to solve very simple to declare the variable as public Static String

  • In that case you can answer your own question, so help other people with the same problem.

  • So I solved //declare the variable public Static String keepsPlaca; //takes the value of the faithful text and stores it in the variables guardarPlaca = fieldPlaca.gettext(); System.out.println(guardarPlaca);

  • Resolved like this public Static String keeperPlate; //declare the variable in class 1 //take the values of the faithful text and store in the variables keeperPlaca = fieldPlaca.gettext(); Class 2 //variable flame of another class Hmlcontroller class = new Hmlcontroller(); //creates a new variable for that class String plate = Hmlcontroller.guardarPlaca; //method to insert textual plate into the site field Webelement placadispositive = driver.findElement(By.id("plate"); placadispositive.(clear(); placadispositivo.Sendkeys(String.valueOf(plate));//insert into the field

  • Answer in the field below and click on "publish your reply", this part is only for comments ^^

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.