1

I want my math online video to play automatically so I've been working on selenium. Everything is done well but the problem occurs the moment I try to play the video. Other elements of this page appear first and then the video with play button appears. I want to press that button automatically.

I thought my problem caused because of loading time so I tried some kind of delaying stuff.

implicitly_wait()
time.sleep()

but after that waiting, nothing happened and an error message came out.

This is my code.

from selenium import webdriver
import time
driver = webdriver.Chrome('./chromedriver')

driver.implicitly_wait(3)
driver.get('http://eclass.seoulxxxx.ac.kr/ilos/main/member/login_form.acl')

elem = driver.find_element_by_id("usr_id")
elem.send_keys("xxxx")
elem = driver.find_element_by_id("usr_pwd")
elem.send_keys("xxxx")
elem.submit()

driver.find_element_by_xpath('//*[@title="Math_2-1 강의실 들어가기"]').click()

driver.find_element_by_id("week-4").click()

driver.find_element_by_xpath('//*[@src="/ilos/images/ko/btn_start_learning.gif"]').click()

time.sleep(8)
driver.find_element_by_class_name('vc-front-screen-play-btn').click()
driver.find_element_by_xpath('//div[@class="vc-front-screen-play-btn"]').click()

Neither of two worked.

The error message in cmd says

[0116/205351.565:ERROR:gl_surface_egl.cc(537)] EGL Driver message (Error) eqlQueryDeviceAttribEXT: Bad attribute.

Can you see what's the problem?

2
  • 1
    @MateMrše While you edit questions please don't add <blockquotes> to the error trace logs. Doing so debugging becomes difficult as the error messages in the error stack trace gets word wrapped. Commented Jan 16, 2019 at 14:26
  • @DebanjanB Thanks for the heads-up! Commented Jan 16, 2019 at 14:33

1 Answer 1

2

Add expected condition (to be clickable) before clicking the play button:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//div[@class="vc-front-screen-play-btn"]')));
driver.find_element_by_xpath('//div[@class="vc-front-screen-play-btn"]').click();

Make sure to use the imports

Sign up to request clarification or add additional context in comments.

4 Comments

What do you mean? What I wanted to say is to add the import to the already existing one.
You use just one line: WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//div[@class="vc-front-screen-play-btn"]'))).click().
What i need to do is just use that code ?? I tried with this code but still doesn't work..
You need to add this code to yours, just before the driver.find_element_by_xpath('//div[@class="vc-front-screen-play-btn"]').click() line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.