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?
– Gustavo Fragoso
I was able to solve very simple to declare the variable as public Static String
– Carol
In that case you can answer your own question, so help other people with the same problem.
– Gustavo Fragoso
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);
– Carol
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
– Carol
Answer in the field below and click on "publish your reply", this part is only for comments ^^
– Gustavo Fragoso