fix
This commit is contained in:
parent
659e7d3664
commit
ca4f97c07b
40
V6.py
40
V6.py
|
@ -83,6 +83,7 @@ def close_tab(tab, SwitchTo=0) -> None:
|
||||||
driver.switch_to.window(driver.window_handles[SwitchTo])
|
driver.switch_to.window(driver.window_handles[SwitchTo])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
|
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
|
||||||
# override is the number of question, by default, it's the number of question in this specific quiz. Can be useful in some case, where the program crashes before finishing the quiz
|
# override is the number of question, by default, it's the number of question in this specific quiz. Can be useful in some case, where the program crashes before finishing the quiz
|
||||||
def play_quiz2(override=10) -> None:
|
def play_quiz2(override=10) -> None:
|
||||||
|
@ -91,26 +92,27 @@ def play_quiz2(override=10) -> None:
|
||||||
try:
|
try:
|
||||||
# rgpd_popup(driver)
|
# rgpd_popup(driver)
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
page_html = driver.page_source
|
|
||||||
secret_answer = search('IG:"([^"]+)"', page_html)[1] # variable used to calculate offset
|
|
||||||
answers_values = search('data-option="([^"]+)"', page_html)[1]
|
|
||||||
offset = int(secret_answer[-2:], 16) # the last two character converted to int are the offset
|
|
||||||
correct_answer_value = search('correctAnswer":"([0-9]+)', page_html)[1]
|
|
||||||
|
|
||||||
somme = 0
|
|
||||||
for answer in answers_values:
|
|
||||||
somme += ord(answer)
|
|
||||||
|
|
||||||
if somme + offset == int(correct_answer_value):
|
js_function = """
|
||||||
answer_elem = driver.find_element(By.ID, "rqAnswerOption0")
|
function get_correct_answer(){
|
||||||
answer_elem.click()
|
function br(n) { for (var r, t = 0, i = 0; i < n.length; i++)t += n.charCodeAt(i); return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString() } // Ms check function
|
||||||
if g.log:
|
function namedRAValue() { //allow calls to getRAvalue
|
||||||
progressBar(j, 10, name="quiz 2")
|
return _w.getRAValue()
|
||||||
else:
|
};
|
||||||
answer_elem = driver.find_element(By.ID, "rqAnswerOption1")
|
if (br(document.getElementById("rqAnswerOption0").attributes["data-option"].value) == namedRAValue()){
|
||||||
answer_elem.click()
|
return(0);
|
||||||
if g.log:
|
}
|
||||||
progressBar(j, 10, name="quiz 2")
|
else {
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return(get_correct_answer())
|
||||||
|
"""
|
||||||
|
correct_answer_value = driver.execute_script(js_function)
|
||||||
|
answer_elem = driver.find_element(By.ID, f"rqAnswerOption{correct_answer_value}")
|
||||||
|
answer_elem.click()
|
||||||
|
if g.log:
|
||||||
|
progressBar(j, 10, name="quiz 2")
|
||||||
|
|
||||||
except exceptions.ElementNotInteractableException as e:
|
except exceptions.ElementNotInteractableException as e:
|
||||||
driver.execute_script("arguments[0].click();", answer_elem)
|
driver.execute_script("arguments[0].click();", answer_elem)
|
||||||
|
|
Loading…
Reference in New Issue