'Scenario: Language menu works correctly in Video component, checks closed captions
Given the course has a Video component in "Youtube" mode
And I have defined multiple language transcripts for the videos
And I make sure captions are closed
And I see video menu "language" with correct items
And I select language with code "en"
Then I see "Welcome to edX." text in the closed captions
And I select language with code "zh"
Then I see "æä»¬ä»å€©èŠè®²çé¢ç®æ¯" text in the closed captions'

def test_video_language_menu_working_closed_captions(self):

    self.assets.extend(['chinese_transcripts.srt', 'subs_3_yD_cEKoCk.srt.sjson'])
    data = {'transcripts': {'zh': 'chinese_transcripts.srt'}, 'sub': '3_yD_cEKoCk'}
    self.metadata = self.metadata_for_mode('youtube', additional_data=data)
    self.navigate_to_video()
    self.video.show_closed_captions()
    correct_languages = {'en': 'English', 'zh': 'Chinese'}
    self.assertEqual(self.video.caption_languages, correct_languages)
    self.video.click_player_button('play')
    self.video.wait_for_position('0:03')
    self.video.click_player_button('pause')
    self.video.select_language('en')
    self.video.click_transcript_line(line_no=1)
    self._verify_closed_caption_text('Welcome    to    edX.')
    self.video.select_language('zh')
    unicode_text = '\xe6\x88\x91\xe4\xbb\xac\xe4\xbb\x8a\xe5\xa4\xa9\xe8\xa6\x81\xe8\xae\xb2\xe7\x9a\x84\xe9\xa2\x98\xe7\x9b\xae\xe6\x98\xaf'.decode('utf-8')
    self.video.click_transcript_line(line_no=1)
    self._verify_closed_caption_text(unicode_text)
