public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aditya Toshniwal <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][RM3936] Feature tests failing intermittently for SQL editor related test cases
Date: Tue, 29 Jan 2019 19:06:12 +0530
Message-ID: <CAM9w-_koTkQyNKkEKBdJ9tTJ74gcSD59_YvOqA_iaiT-xACShQ@mail.gmail.com> (raw)
In-Reply-To: <CAM9w-_mR80KgZa5vSODppxJzushpWt14p2+Yo-6hdAJvE4WFmA@mail.gmail.com>
References: <CAM9w-_mx9D_W-H3x3HGq_pEcBiT7V65TWrW1B+Vin_VPXp=vEw@mail.gmail.com>
<CA+OCxozDzm8EpLTux7-C=wy3XZSpUHdCxFKo=9dv+eWKsbJD5A@mail.gmail.com>
<CAM9w-_n=7XEuFW+Vzi+xQgiXoJRdHu5-RrPS1QNwP7Ew9v6qdQ@mail.gmail.com>
<CA+OCxowUyiAP7rrV1nttj4kpKUednObSkVYoEbhtMvqb0CV8Ng@mail.gmail.com>
<CAM9w-_mR80KgZa5vSODppxJzushpWt14p2+Yo-6hdAJvE4WFmA@mail.gmail.com>
Hi Hackers,
Attached is the updated patch. I have changed fill_input_by_field_name
function to use javascript to set values of text boxes and the selector is
changed from xpath to CSS with a :not(:disabled) clause. With this, test
case will fail if tried to set the value of a disabled input.
Kindly review.
On Mon, Jan 28, 2019 at 5:44 PM Aditya Toshniwal <
[email protected]> wrote:
>
>
> On Mon, Jan 28, 2019 at 5:39 PM Dave Page <[email protected]> wrote:
>
>> On Mon, Jan 28, 2019 at 12:05 PM Aditya Toshniwal
>> <[email protected]> wrote:
>> >
>> > Hi Dave,
>> >
>> > On Mon, Jan 28, 2019 at 5:01 PM Dave Page <[email protected]> wrote:
>> >>
>> >> Hi
>> >>
>> >> On Mon, Jan 28, 2019 at 7:00 AM Aditya Toshniwal
>> >> <[email protected]> wrote:
>> >> >
>> >> > Hi Hackers,
>> >> >
>> >> > Attached is the patch to fix failing SQL editor related feature
>> tests.
>> >> > The failure is occurring mostly because of send_keys function of
>> selenium which sometimes does not input the complete text. The change will
>> use Codemirror javascript object to set the text.
>> >> >
>> >> > I have also added new args flag "--modules" which can be used after
>> --pkg where you can test a specific module file under the pkg. This is not
>> so useful for build but definitely helpful for the developers.
>> >>
>> >> One of the most common failures I see is failure to fill in the
>> >> details on the Add Server dialogue (it might type half of an entry,
>> >> then just hang). Should we get rid of all uses of send_keys?
>> >
>> > Setting the text using javascript executor can be done. send_keys
>> simulate an actual person, so if you try to set a disabled text box using
>> send_keys, it won't. Places where disabled fields doesn't matter, send_keys
>> can be removed.
>>
>> Can't we just do something like:
>>
>> if input.disabled == false:
>> input.value = 'Foo';
>> else:
>> raise exception ....
>>
> I'll check if this can be done. Will get back.
>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
> --
> Thanks and Regards,
> Aditya Toshniwal
> Software Engineer | EnterpriseDB Software Solutions | Pune
> "Don't Complain about Heat, Plant a tree"
>
--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Attachments:
[application/octet-stream] RM3936_v2.patch (7.6K, 3-RM3936_v2.patch)
download | inline diff:
diff --git a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
index 1c89393d..4e11f994 100644
--- a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
+++ b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
@@ -83,6 +83,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.page.find_by_css_selector(
".pg-bg-more-details").click()
+ backup_file = None
# Check for XSS in Backup details
if self.is_xss_check:
self._check_detailed_window_for_xss('Backup')
@@ -99,7 +100,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.assertIn("pg_dump", str(command))
- backup_file = None
if command:
backup_file = command[int(command.find('--file')) +
8:int(command.find('--host')) - 2]
diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py
index e45e06b7..d1c6ce63 100644
--- a/web/pgadmin/utils/route.py
+++ b/web/pgadmin/utils/route.py
@@ -56,7 +56,7 @@ class TestsGeneratorRegistry(ABCMeta):
ABCMeta.__init__(cls, name, bases, d)
@classmethod
- def load_generators(cls, pkg_root, exclude_pkgs):
+ def load_generators(cls, pkg_root, exclude_pkgs, for_modules=[]):
cls.registry = dict()
@@ -64,6 +64,13 @@ class TestsGeneratorRegistry(ABCMeta):
all_modules += find_modules(pkg_root, False, True)
+ # If specific modules are to be tested, exclude others
+ if len(for_modules) > 0:
+ all_modules = [module_name
+ for module_name in all_modules
+ for fmod in for_modules
+ if module_name.endswith(fmod)]
+
# Check for SERVER mode
for module_name in all_modules:
try:
diff --git a/web/regression/README b/web/regression/README
index 7e668cfd..6a68d36f 100644
--- a/web/regression/README
+++ b/web/regression/README
@@ -167,6 +167,14 @@ Python Tests:
Example 2) Run test framework for 'database' node
run 'python runtests.py --pkg browser.server_groups.servers.databases.tests'
+- Execute test framework for certain modules of a test pkg
+
+ Example 1) Run test framework for 'sqleditor' package and test_start_running_query module
+ run 'python runtests.py --pkg tools.sqleditor --modules test_start_running_query'
+
+ Example 2) Run test framework for 'sqleditor' package and test_start_running_query,test_query_tool_fs_utils modules
+ run 'python runtests.py --pkg tools.sqleditor --modules test_start_running_query,test_query_tool_fs_utils'
+
- Exclude a package and its subpackages when running tests:
Example: exclude feature tests but run all others:
diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py
index 0c8f0fa3..cd4370e5 100644
--- a/web/regression/feature_utils/pgadmin_page.py
+++ b/web/regression/feature_utils/pgadmin_page.py
@@ -224,38 +224,60 @@ class PgadminPage:
"clicking the element not to throw an exception", click_succeeded
)
- def fill_input_by_field_name(self, field_name, field_content):
- field = self.find_by_xpath("//input[@name='" + field_name + "']")
+ def fill_input_by_field_name(self, field_name, field_content,
+ input_keys=False):
+ field = self.find_by_css_selector(
+ "input[name='" + field_name + "']:not(:disabled)")
backspaces = [Keys.BACKSPACE] * len(field.get_attribute('value'))
field.click()
- field.send_keys(backspaces)
- field.send_keys(str(field_content))
- self.wait_for_input_field_content(field_name, field_content)
- def fill_codemirror_area_with(self, field_content):
+ # Use send keys if input_keys true, else use javascript to set content
+ if input_keys:
+ field.send_keys(backspaces)
+ field.send_keys(str(field_content))
+ self.wait_for_input_field_content(field_name, field_content)
+ else:
+ self.driver.execute_script(
+ "arguments[0].setAttribute('value', arguments[1])",
+ field, field_content)
+
+ action = ActionChains(self.driver)
+ action.key_down(Keys.ARROW_DOWN)
+ action.perform()
+
+ def fill_codemirror_area_with(self, field_content, input_keys=False):
def find_codemirror(driver):
try:
driver.switch_to.default_content()
driver.switch_to_frame(
driver.find_element_by_tag_name("iframe"))
- element = driver.find_element_by_xpath(
- "//pre[contains(@class,'CodeMirror-line')]/../../../"
- "*[contains(@class,'CodeMirror-code')]")
+ element = driver.find_element_by_css_selector(
+ "#output-panel .CodeMirror")
if element.is_displayed() and element.is_enabled():
return element
except (NoSuchElementException, WebDriverException):
return False
+ codemirror_ele = WebDriverWait(
+ self.driver, timeout=self.timeout, poll_frequency=0.01)\
+ .until(find_codemirror,
+ "Timed out waiting for codemirror to appear")
+
time.sleep(1)
- WebDriverWait(self.driver, timeout=self.timeout, poll_frequency=0.01).\
- until(find_codemirror, "Timed out waiting for codemirror "
- "to appear").click()
- time.sleep(1)
+ codemirror_ele.click()
- action = ActionChains(self.driver)
- action.send_keys(field_content)
- action.perform()
+ # Use send keys if input_keys true, else use javascript to set content
+ if input_keys:
+ action = ActionChains(self.driver)
+ action.send_keys(field_content)
+ action.perform()
+ else:
+ self.driver.execute_script(
+ "arguments[0].CodeMirror.setValue(arguments[1]);"
+ "arguments[0].CodeMirror.setCursor("
+ "arguments[0].CodeMirror.lineCount(),0);",
+ codemirror_ele, field_content)
def click_tab(self, tab_name):
WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable(
diff --git a/web/regression/runtests.py b/web/regression/runtests.py
index b023703d..116a0a16 100644
--- a/web/regression/runtests.py
+++ b/web/regression/runtests.py
@@ -233,9 +233,14 @@ def get_test_modules(arguments):
if arguments['pkg'] is None or arguments['pkg'] == "all":
TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs)
else:
+ for_modules = []
+ if arguments['modules'] is not None:
+ for_modules = arguments['modules'].split(',')
+
TestsGeneratorRegistry.load_generators('pgadmin.%s' %
arguments['pkg'],
- exclude_pkgs)
+ exclude_pkgs,
+ for_modules)
# Sort module list so that test suite executes the test cases sequentially
module_list = TestsGeneratorRegistry.registry.items()
@@ -266,6 +271,10 @@ def add_arguments():
'--default_browser',
help='Executes the feature test in specific browser'
)
+ parser.add_argument(
+ '--modules',
+ help='Executes the feature test for specific modules in pkg'
+ )
arg = parser.parse_args()
return arg
view thread (15+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][RM3936] Feature tests failing intermittently for SQL editor related test cases
In-Reply-To: <CAM9w-_koTkQyNKkEKBdJ9tTJ74gcSD59_YvOqA_iaiT-xACShQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox