
import random

import pytest

from ..pages.home import HomePage


@pytest.mark.nondestructive
def test_change_language(base_url, selenium):
    page = HomePage(base_url, selenium).open()
    initial = page.footer.language
    # avoid selecting the same language or locales that have homepage redirects
    excluded = [initial, 'ja', 'zh-TW', 'zh-CN']
    available = [l for l in page.footer.languages if l not in excluded]
    new = random.choice(available)
    page.footer.select_language(new)
    assert new in selenium.current_url, 'Language is not in URL'
    assert new == page.footer.language, 'Language has not been selected'


import random

import pytest

from ..pages.home import HomePage


@pytest.mark.nondestructive
def test_change_language(base_url, selenium):
    page = HomePage(base_url, selenium).open()
    initial = page.footer.language
    # avoid selecting the same language or locales that have homepage redirects
    excluded = [initial, 'ja', 'ja-JP-mac', 'zh-TW', 'zh-CN']
    available = [l for l in page.footer.languages if l not in excluded]
    new = random.choice(available)
    page.footer.select_language(new)
    assert new in selenium.current_url, 'Language is not in URL'
    assert new == page.footer.language, 'Language has not been selected'

Exclude ja-JP-mac on homepage language select functional test
Exclude ja-JP-mac on homepage language select functional test

  
  import random
  
  import pytest
  
  from ..pages.home import HomePage
  
  
  @pytest.mark.nondestructive
  def test_change_language(base_url, selenium):
      page = HomePage(base_url, selenium).open()
      initial = page.footer.language
      # avoid selecting the same language or locales that have homepage redirects
-     excluded = [initial, 'ja', 'zh-TW', 'zh-CN']
+     excluded = [initial, 'ja', 'ja-JP-mac', 'zh-TW', 'zh-CN']
      available = [l for l in page.footer.languages if l not in excluded]
      new = random.choice(available)
      page.footer.select_language(new)
      assert new in selenium.current_url, 'Language is not in URL'
      assert new == page.footer.language, 'Language has not been selected'
  
Exclude ja-JP-mac on homepage language select functional test
## Code Before:

import random

import pytest

from ..pages.home import HomePage


@pytest.mark.nondestructive
def test_change_language(base_url, selenium):
    page = HomePage(base_url, selenium).open()
    initial = page.footer.language
    # avoid selecting the same language or locales that have homepage redirects
    excluded = [initial, 'ja', 'zh-TW', 'zh-CN']
    available = [l for l in page.footer.languages if l not in excluded]
    new = random.choice(available)
    page.footer.select_language(new)
    assert new in selenium.current_url, 'Language is not in URL'
    assert new == page.footer.language, 'Language has not been selected'

## Instruction:
Exclude ja-JP-mac on homepage language select functional test
## Code After:

import random

import pytest

from ..pages.home import HomePage


@pytest.mark.nondestructive
def test_change_language(base_url, selenium):
    page = HomePage(base_url, selenium).open()
    initial = page.footer.language
    # avoid selecting the same language or locales that have homepage redirects
    excluded = [initial, 'ja', 'ja-JP-mac', 'zh-TW', 'zh-CN']
    available = [l for l in page.footer.languages if l not in excluded]
    new = random.choice(available)
    page.footer.select_language(new)
    assert new in selenium.current_url, 'Language is not in URL'
    assert new == page.footer.language, 'Language has not been selected'
