I am getting this strange scenario.
Been searching for a long time without success, what is going on?
Let me explain you:
I am trying to create an automation in a webpage, i have to enter a
specific value in a dinamic table and after performing a "ENTER" event
it is necessary to select the first row shown:
After running my code i got this but the row shown is not been selected, it is stuck:
This is my code:
package first;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Script_codes {
public static void main(String[] args){
System.setProperty("webdriver.chrome.driver","C:\Users\Steve\Desktop\Me\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://stage.nbm2.test/backend");
driver.findElement(By.id("username")).sendKeys("test");
driver.findElement(By.id("login")).sendKeys("test");
driver.findElement(By.xpath("//*[@id="login-form"]/fieldset/div[3]/div[2]/button")).click();
driver.findElement(By.xpath("//*[@id="menu-magento-backend-stores"]/a")).click();
driver.findElement(By.xpath("//*[@id="menu-magento-backend-stores"]/div/ul/li[2]/ul/li[2]/div/ul/li[3]/a")).click();
driver.findElement(By.xpath("//*[@id="attributeGrid_filter_frontend_label"]")).sendKeys("linea");
driver.findElement(By.xpath("//*[@id="attributeGrid_filter_frontend_label"]")).sendKeys(Keys.ENTER);
driver.findElement(By.className("col-label col-frontend_label")).click();
}
}
I have tried many different ways but it seems not to be working, what can i do?
Expected output:
2
Answers
I was able to solved my problem by using:
instead of:
I would first try the following to see if timing is the issue:
If this works, I expect it will be fairly simple to identify which step(s) needs extra time. For this wait, I suggest you implement the
WebDriverWait
class for better stability and execution time.