I have a question. I am buildin my first script for JMeter / WebDriver Sampler / Script Language groovy
This 2 fields works great:
var txtEmail = WDS.browser.findElement(org.openqa.selenium.By.id("email"));
txtEmail.sendKeys('example1@hotmail.com');
Thread.sleep(1000);
var txtPassword = WDS.browser.findElement(org.openqa.selenium.By.id("password-field"));
txtPassword.sendKeys('Passexample1');
Thread.sleep(1000);
But i don't know how to automate the click of a button that doesn't have properties "id" and "name". Just have class:
<input _ngcontent-dqo-c0="" class=" btn mt-3 mb-4 text-uppercase btn-primary" type="submit" value="Iniciar Sesión">
How i can do that?
Automate a button click
From what I can see you could stick to value
attribute
Something like:
WDS.browser.findElement(org.openqa.selenium.By.cssSelector("input[value='Iniciar Sesión'")).click()
More information: CSS Selectors
Also one of the Top 15 UI Test Automation Best Practices states:
NEVER use
Thread.sleep()
unless there are specific test requirements
so it worth considering going for Explicit Wait instead