From 72311dbcda3689c46bc6f5e9b68d4a14ec7b161f Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 17 Aug 2017 15:41:53 +0530 Subject: changed import from settings as per new code sever --- yaksh/live_server_tests/load_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/live_server_tests') diff --git a/yaksh/live_server_tests/load_test.py b/yaksh/live_server_tests/load_test.py index 47d267c..ee4549d 100644 --- a/yaksh/live_server_tests/load_test.py +++ b/yaksh/live_server_tests/load_test.py @@ -26,7 +26,7 @@ class YakshSeleniumTests(StaticLiveServerTestCase): "yaksh.cpp_code_evaluator.CppCodeEvaluator" settings.code_evaluators['bash']['standardtestcase'] = \ "yaksh.bash_code_evaluator.BashCodeEvaluator" - code_server_pool = ServerPool(ports=settings.SERVER_PORTS, pool_port=settings.SERVER_POOL_PORT) + code_server_pool = ServerPool(n=settings.N_CODE_SERVERS, pool_port=settings.SERVER_POOL_PORT) cls.code_server_pool = code_server_pool cls.code_server_thread = t = Thread(target=code_server_pool.run) t.start() -- cgit From dd617ed43eb67cc6879605c05eaaad99d377e0cc Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 17 Aug 2017 16:44:59 +0530 Subject: Added 8 seconds sleep in selenium test for now. As implicit wait is not functioning as desired. Added sleep for now. Since new exam interface has AJAX request response, so interface sets a blank div on top of all divs to prevent further events till a response is received. So selenium does not get the required HTML element at that period. And 8 seconds because for infinite loop server responds after 4 seconds. --- yaksh/live_server_tests/selenium_test.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'yaksh/live_server_tests') diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py index 277f08e..00e1847 100644 --- a/yaksh/live_server_tests/selenium_test.py +++ b/yaksh/live_server_tests/selenium_test.py @@ -7,6 +7,7 @@ from selenium.common.exceptions import WebDriverException import multiprocessing import argparse +import time class SeleniumTestError(Exception): pass @@ -48,6 +49,7 @@ class SeleniumTest(): def submit_answer(self, question_label, answer, loop_count=1): self.driver.implicitly_wait(2) for count in range(loop_count): + time.sleep(15) self.driver.find_element_by_link_text(question_label).click() submit_answer_elem = self.driver.find_element_by_id("check") self.driver.execute_script('global_editor.editor.setValue({});'.format(answer)) -- cgit From 055d0d1c51f90b4496a096a13bab5e4978fe9b92 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Tue, 22 Aug 2017 14:58:50 +0530 Subject: Added custom expected condition class To check if the ontop div display is none. If so then the selenium will proceed ahead else wait for the div property to change. Currently I have not specified the actual exception in try except, will add later Modified JS to handle ontop div --- yaksh/live_server_tests/selenium_test.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'yaksh/live_server_tests') diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py index 00e1847..859d032 100644 --- a/yaksh/live_server_tests/selenium_test.py +++ b/yaksh/live_server_tests/selenium_test.py @@ -7,7 +7,23 @@ from selenium.common.exceptions import WebDriverException import multiprocessing import argparse -import time + + +class ElementDisplay(object): + '''Custom expected condition ''' + def __init__(self, locator): + self.locator = locator + + def __call__(self, driver): + try: + element = EC._find_element(driver, self.locator) + a = element.value_of_css_property("display") == "none" + print(a) + return a + except Exception as e: + print(e) + return False + class SeleniumTestError(Exception): pass @@ -49,11 +65,13 @@ class SeleniumTest(): def submit_answer(self, question_label, answer, loop_count=1): self.driver.implicitly_wait(2) for count in range(loop_count): - time.sleep(15) + print("in") self.driver.find_element_by_link_text(question_label).click() submit_answer_elem = self.driver.find_element_by_id("check") self.driver.execute_script('global_editor.editor.setValue({});'.format(answer)) submit_answer_elem.click() + WebDriverWait(self.driver, 90).until(ElementDisplay( + (By.XPATH, "//*[@id='ontop']"))) def test_c_question(self, question_label): # Incorrect Answer -- cgit From 3d9bce5471d04bf50e03155d3cd67bdae44a4fcc Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 31 Aug 2017 16:28:57 +0530 Subject: updated travis config and added print to debug on travis --- yaksh/live_server_tests/selenium_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'yaksh/live_server_tests') diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py index 859d032..d9ae9cd 100644 --- a/yaksh/live_server_tests/selenium_test.py +++ b/yaksh/live_server_tests/selenium_test.py @@ -75,7 +75,7 @@ class SeleniumTest(): def test_c_question(self, question_label): # Incorrect Answer - loop_count = 10 + loop_count = 3 answer = '\"int add(int a, int b, int c)\\n{return;}\"' self.submit_answer(question_label, answer, loop_count) @@ -91,7 +91,7 @@ class SeleniumTest(): def test_python_question(self, question_label): # Incorrect Answer - loop_count = 10 + loop_count = 3 answer = '\"def is_palindrome(s):\\n return s\"' self.submit_answer(question_label, answer, loop_count) @@ -107,7 +107,7 @@ class SeleniumTest(): def test_bash_question(self, question_label): # Incorrect Answer - loop_count = 10 + loop_count = 3 answer = '\"#!/bin/bash\\nls\"' self.submit_answer(question_label, answer, loop_count) -- cgit From e2c65655dcdc5558cfb4ab668c3012024d27ac75 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Fri, 1 Sep 2017 16:51:37 +0530 Subject: Removed all the checkpoints set for selenium tests on travis javascript strings includes method changed to indexOf, as includes belongs to ES6. This was the main reason for failure of selenium tests on travis. --- yaksh/live_server_tests/selenium_test.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'yaksh/live_server_tests') diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py index d9ae9cd..21a9e42 100644 --- a/yaksh/live_server_tests/selenium_test.py +++ b/yaksh/live_server_tests/selenium_test.py @@ -17,11 +17,8 @@ class ElementDisplay(object): def __call__(self, driver): try: element = EC._find_element(driver, self.locator) - a = element.value_of_css_property("display") == "none" - print(a) - return a + return element.value_of_css_property("display") == "none" except Exception as e: - print(e) return False @@ -65,7 +62,6 @@ class SeleniumTest(): def submit_answer(self, question_label, answer, loop_count=1): self.driver.implicitly_wait(2) for count in range(loop_count): - print("in") self.driver.find_element_by_link_text(question_label).click() submit_answer_elem = self.driver.find_element_by_id("check") self.driver.execute_script('global_editor.editor.setValue({});'.format(answer)) @@ -75,7 +71,7 @@ class SeleniumTest(): def test_c_question(self, question_label): # Incorrect Answer - loop_count = 3 + loop_count = 10 answer = '\"int add(int a, int b, int c)\\n{return;}\"' self.submit_answer(question_label, answer, loop_count) @@ -91,7 +87,7 @@ class SeleniumTest(): def test_python_question(self, question_label): # Incorrect Answer - loop_count = 3 + loop_count = 10 answer = '\"def is_palindrome(s):\\n return s\"' self.submit_answer(question_label, answer, loop_count) @@ -107,7 +103,7 @@ class SeleniumTest(): def test_bash_question(self, question_label): # Incorrect Answer - loop_count = 3 + loop_count = 10 answer = '\"#!/bin/bash\\nls\"' self.submit_answer(question_label, answer, loop_count) -- cgit From 7aac7a18e4e393b7e267d3687be73a7fdfb7b400 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Tue, 5 Sep 2017 19:27:15 +0530 Subject: Removed redundancy from request handler JS --- yaksh/live_server_tests/load_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'yaksh/live_server_tests') diff --git a/yaksh/live_server_tests/load_test.py b/yaksh/live_server_tests/load_test.py index ee4549d..5ab1cc2 100644 --- a/yaksh/live_server_tests/load_test.py +++ b/yaksh/live_server_tests/load_test.py @@ -26,7 +26,9 @@ class YakshSeleniumTests(StaticLiveServerTestCase): "yaksh.cpp_code_evaluator.CppCodeEvaluator" settings.code_evaluators['bash']['standardtestcase'] = \ "yaksh.bash_code_evaluator.BashCodeEvaluator" - code_server_pool = ServerPool(n=settings.N_CODE_SERVERS, pool_port=settings.SERVER_POOL_PORT) + code_server_pool = ServerPool( + n=settings.N_CODE_SERVERS, pool_port=settings.SERVER_POOL_PORT + ) cls.code_server_pool = code_server_pool cls.code_server_thread = t = Thread(target=code_server_pool.run) t.start() -- cgit