<commit_before>package ru.stqa.training.selenium.LiteCart;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;

import static org.junit.Assert.assertTrue;


public class AdminMainMenu extends LoginLocal{


    @Test

    public void menuClick() {

        String fistPointMenu = "//ul[@id='box-apps-menu']/li";
        String nextMenu = "li.selected+*";
//        String nextSubMenu = "//ul[@class='docs']/li[@class='selected']/following-sibling::li[1]";
        String headerCssSelector = "td#content h1";

        LoginAdmin(new LoginData("admin", "admin"));

        String currentLocator = fistPointMenu;

        wd.findElement(By.xpath(currentLocator)).click();
        assert wd.findElement(By.cssSelector(headerCssSelector)).isDisplayed();


        currentLocator = nextMenu;
        do {
            wd.findElement(By.cssSelector(currentLocator)).click();
            assert wd.findElement(By.cssSelector(headerCssSelector)).isDisplayed();

        } while (isElementPresent(wd, nextMenu));
    }


        boolean isElementPresent(WebDriver wd, String cssSelector) {
            try {
                wd.findElement(By.cssSelector(cssSelector));
                return true;
            } catch (NoSuchElementException ex) {
                return false;
            }




//        Читерский способ ))
//        wd.findElement(By.xpath("//span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[2]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[2]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[2]/ul/li[2]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[4]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[5]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[6]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[7]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[8]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[9]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[3]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[10]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[6]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[7]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();<commit_msg>4 задание + Курс про NodeJS+ йа все упростил<commit_after>package ru.stqa.training.selenium.LiteCart;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;

import static org.junit.Assert.assertTrue;


public class AdminMainMenu extends LoginLocal{


    @Test
    public void menuClick() {

        String fistPointMenu = "#app-";
        String nextMenu = "li.selected+*";
        String headerCssSelector = "td#content h1";

        LoginAdmin(new LoginData("admin", "admin"));

        wd.findElement(By.cssSelector(fistPointMenu)).click();
        assert wd.findElement(By.cssSelector(headerCssSelector)).isDisplayed();
        do {
            wd.findElement(By.cssSelector(nextMenu)).click();
            assert wd.findElement(By.cssSelector(headerCssSelector)).isDisplayed();

        } while (isElementPresent(wd, nextMenu));
    }

        boolean isElementPresent(WebDriver wd, String cssSelector) {
            try {
                wd.findElement(By.cssSelector(cssSelector));
                return true;
            } catch (NoSuchElementException ex) {
                return false;
            }
//        Читерский способ ))
//        wd.findElement(By.xpath("//span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[2]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[2]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[2]/ul/li[2]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[4]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[5]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[6]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[7]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[8]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[9]/a/span")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[3]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[10]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[6]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
//        wd.findElement(By.xpath("//li[7]/a/span[2]")).click();
//        assert wd.findElement(By.cssSelector("#content > h1")).isDisplayed();
{'fraction_non_alphanumeric': 0.2001489203276247, 'fraction_numerical': 0.011020104244229337, 'mean_word_length': 2.9692671394799053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2280364', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2215, 'n_words': 252}