sendKeys How to check that it works? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

sendKeys How to check that it works?

I have a project to check a questions game site,I use JUNIT to check the site So I have to write three questions and four possible answers to each question, mark the correct answer and then play the game. So in question field 1 I wrote A using the command SENDKEYS But how do I check that he actually wrote A in the qustion field? I tried driver.getText and element.getAttribute ("value") But JUINT marks the line as an error in red WebDriver driver = new ChromeDriver(); driver.get("https://trivia.com/"); //Step 2: Click on the Start button if(driver.getPageSource().contains("Start")==true){driver.findElement(By.id("startB")).click(); assertEquals(true,driver.findElement(By.name("question")).isEnabled());} else{fail("Error: url is wrong");} //Step 3: Write your first question if(driver.getPageSource().contains("question number: 1")==true){driver.findElement(By.name("question")).sendKeys("A"); assertEquals(true,driver.findElement(By.name("question")).isEnabled());} else{fail("Error: Not the question number 1 screen");}

23rd Jul 2020, 7:38 AM
Aviv Levi
1 Answer
+ 1
Please don't post irrevelant questions here. Follow the forum rules and regulations. https://www.sololearn.com/Discuss/1316935/?ref=app Hope you delete this as soon as possible
23rd Jul 2020, 7:47 AM
JaScript
JaScript - avatar