E
E
eldgammel2021-04-21 00:35:20
Software testing
eldgammel, 2021-04-21 00:35:20

After closing the modal window, selenium stops seeing the locators. Why?

Hello, I'm new, don't judge too harshly. Thanks for the answer in advance.
Selenium writing in Java Selenium
steps:
Opens the browser => clicks on the login button => pops up a modal window => enters mail => enters password => clicks on "login" => and that's it ... stops seeing further locators and go by them.
Tried to put implicit waits, alas, it did not help.
In the console it says that the last step is not a clique and it re-clicks on the previous one

org.openqa.selenium.WebDriverException: unknown error: Element <span class="t-crop t-crop--one-l">...</span> is not clickable at point (924, 673). Other element would receive the click: <div data-modal="Login" aria-expanded="true" class="vm--overlay">...</div>


The code:
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import javax.swing.*;
import java.time.Duration;

public class Main {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver"); // путь к драйверу
        WebDriver driver = new ChromeDriver(); // запускаем Chrome
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); // настроили неявные ожидания

        try {
            driver.get("https://turk.com/"); // запускаем сайт
            Thread.sleep(1000);
            WebElement signIn = (new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class=\"header__user-nav\"]//ul//li[3]//a"))));
            signIn.click();

            WebElement emaiField = driver.findElement(By.xpath("//div[@class=\"tab__content tab__content--current\"]//div[1]//div//input[@type=\"text\"]"));
            emaiField.click();
            emaiField.sendKeys("[email protected]");

            WebElement passwordField = driver.findElement(By.xpath("//div[@class=\"tab__content tab__content--current\"]//div[1]//div//input[@type=\"password\"]"));
            passwordField.click();
            passwordField.sendKeys("Test-me-test");

            WebElement enterToProfile = driver.findElement(By.xpath("//div[@class=\"modal__btn-wrap\"]//button"));
            enterToProfile.click(); // это последний рабочий шаг, дальше не работает

            WebElement test = (new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class=\"nav__categories-header\"]//a"))));
            test.click(); // именно тут перестает работать, но если удалить предыдущие шаги и оставить ТОЛЬКО это то работает
            
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question