<gh_stars>0
import pytest
import time
import test_002_user_login as Log_in
from test_005_add_new_articles import click_menuitem, read_test_data
from locators import MyArticlePageLocators as MAPL
from locators import ArticlePageLocators as APL


def get_blogpost(drv, title):
    blinks = drv.find_elements(*MAPL.articles_title)
    for blink in blinks:
        if blink.text == title:
            return blink


def test_delete_blog_posts(init_webdriver):
    browser = init_webdriver
    Log_in.sign_in(browser, '<EMAIL>', '1234Asdf', 'tesztelek')
    articles = read_test_data()

    for article in articles['articles']:
        click_menuitem(browser, 'tesztelek')
        time.sleep(2)
        get_blogpost(browser, article['title'])
        article_lnk = get_blogpost(browser, article['title'])
        article_lnk.click()
        time.sleep(2)
        assert article['title'] == browser.find_element(*APL.article_page_title).text, "Cím nem egyezik"
        assert 'tesztelek' == browser.find_element(*APL.author).text, "Más felhasználó bejegyzése töltődött be!"
        browser.find_elements(*APL.delete_article_btn).click()

    assert len(browser.find_elements(*MAPL.articles_links)) == 0

import pytest
import time
import test_002_user_login as Log_in
from test_005_add_new_articles import click_menuitem, read_test_data
from locators import MyArticlePageLocators as MAPL
from locators import ArticlePageLocators as APL


def get_blogpost(drv, title):
    blinks = drv.find_elements(*MAPL.articles_title)
    for blink in blinks:
        if blink.text == title:
            return blink


def test_delete_blog_posts(init_webdriver):
    browser = init_webdriver
    Log_in.sign_in(browser, '<EMAIL>', '1234Asdf', 'tesztelek')
    articles = read_test_data()

    for article in articles['articles']:
        click_menuitem(browser, 'tesztelek')
        time.sleep(2)
        get_blogpost(browser, article['title'])
        article_lnk = get_blogpost(browser, article['title'])
        article_lnk.click()
        time.sleep(2)
        assert article['title'] == browser.find_element(*APL.article_page_title).text, "Cím nem egyezik"
        assert 'tesztelek' == browser.find_element(*APL.author).text, "Más felhasználó bejegyzése töltődött be!"
        browser.find_elements(*APL.delete_article_btn).click()

    assert len(browser.find_elements(*MAPL.articles_links)) == 0