Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__WD_Error() minimizing the amount of messages #290

Merged
merged 73 commits into from
Jul 5, 2022
Merged

__WD_Error() minimizing the amount of messages #290

merged 73 commits into from
Jul 5, 2022

Conversation

mlipok
Copy link
Contributor

@mlipok mlipok commented Apr 10, 2022

Pull request

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.

Please ensure you have read and noticed the checklist below.

Checklist

Put an x in the boxes that apply. If you're unsure about any of them, don't hesitate to ask. We are here to help!

This is simply a reminder of what we are going to look for before merging your code.

  • I have read and noticed the CODE OF CONDUCT document
  • I have read and noticed the CONTRIBUTING document
  • I have added necessary documentation or screenshots (if appropriate)

Types of changes

Please check x the type of change your PR introduces:

  • Bugfix (change which fixes an issue)
  • Feature (change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (functional, structural)
  • Documentation content changes
  • Other (please describe)

What is the current behavior?

Currently UDF throws to many messages to console.

Very often they are duplicated.
for example $sResponseText is showed by __WD_Delete and _WD_DeleteSession

according to the ENUMS order:

Global Enum _
		$_WD_DEBUG_None = 0, _ ; No logging to console
		$_WD_DEBUG_Error, _    ; logging to console in case of Error
		$_WD_DEBUG_Info, _     ; logging to console with additional information
		$_WD_DEBUG_Full        ; logging to console with information for developers of WebDriver UDF

$_WD_DEBUG_Error should show less information than $_WD_DEBUG_Info .

But currently $_WD_DEBUG_Info shows only URL

	__WD_ConsoleWrite($sFuncName & ": URL=" & $sURL, $_WD_DEBUG_Info)

which means that $_WD_DEBUG_Info shows less information than $_WD_DEBUG_Error which shows entire $sResponseText

	Local $sMessage = (($sResponseText) ? ("ResponseText=" & StringLeft($sResponseText, $_WD_RESPONSE_TRIM) & "...") : (""))
	Return SetError(__WD_Error($sFuncName, $iResult, $sMessage), 0, $sResponseText)

What is the new behavior?

More user friendly information in case of $_WD_DEBUG_Error

	Return SetError(__WD_Error($sFuncName, $iResult, "Error occurs with URL=" & $sURL), 0, 

More detailed information in case of $_WD_DEBUG_Info or $_WD_DEBUG_Full

	Local $sMessage = (($sResponseText) ? (" ResponseText=" & StringLeft($sResponseText, $_WD_RESPONSE_TRIM) & "...") : (""))
	__WD_ConsoleWrite($sFuncName & $sMessage, $_WD_DEBUG_Info)

Not duplicated $sResponseText in console.

Additional context

The debug flag may be helpful, but in all honesty it’s so verbose that whenever I’ve tried to look at it, it’s been like trying to find a needle in a haystack and I’m not familiar with the output so I don’t even know what the needle looks like…

System under test

Not related

Remarks:
This is only a modest begining of PR.
If you agree this direction of changes, then entire UDF should be reviewed in the same way.

@mlipok mlipok changed the title __WD_Error() minimizing the number of messages __WD_Error() minimizing the amount of messages Apr 10, 2022
@mlipok
Copy link
Contributor Author

mlipok commented Apr 11, 2022

Waiting on your comments

@Danp2
Copy link
Owner

Danp2 commented Apr 11, 2022

$_WD_DEBUG_Error should show less information than $_WD_DEBUG_Info

Please provide a short code snippet that demonstrates the behavior you describe.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 11, 2022

#include "z:\!!!_SVN_AU3\UDF_Forum\Other_Members\Official_AutoIt_Forum\WebDriver\____ORG_VESION\wd_helper.au3 "
;~ #include "..\wd_helper.au3"

$_WD_DEBUG = $_WD_DEBUG_Full
_WD_DeleteSession("")

image


+CURRENT:
>"Z:\AutoItPortable\App\SciTE\..\AutoIt3.exe" "Z:\!!!_SVN_AU3\UDF_Forum\Other_Members\Official_AutoIt_Forum\WebDriver\Testing\wd_capabilities_TESTING_DeleteSession.au3" /ErrorStdOut /UserParams    
__WD_Delete: URL=HTTP://127.0.0.1:0/session/
__WD_Delete ==> Send / Recv error (6) : ResponseText=WinHTTP request timed out before Webdriver...
_WD_DeleteSession ==> Webdriver Exception (10) : WinHTTP request timed out before Webdriver
>Exit code: 0    Time: 2.464

+NEW PROPOSAL
>"Z:\AutoItPortable\App\SciTE\..\AutoIt3.exe" "Z:\!!!_SVN_AU3\UDF_Forum\Other_Members\Official_AutoIt_Forum\WebDriver\Testing\wd_capabilities_TESTING_DeleteSession.au3" /ErrorStdOut /UserParams    
__WD_Delete ResponseText=WinHTTP request timed out before Webdriver...
__WD_Delete ==> Send / Recv error (6) : Error occurs with URL=HTTP://127.0.0.1:0/session/
_WD_DeleteSession ==> Webdriver Exception (10) : Error occurs when trying to delete session
>Exit code: 0    Time: 2.472

The current version twicely says WinHTTP request timed out before Webdriver

The main idea is to only __WD_Post and __WD_Get and __WD_Delete should show ResponseText with __WD_Error

All other function should'nt do that.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 11, 2022

What is strange to me is that:

__WD_Delete() trims the $sResponseText

_WD_DeleteSession() shows entire $sResponse

@Danp2
Copy link
Owner

Danp2 commented Apr 11, 2022

$_WD_DEBUG_Error should show less information than $_WD_DEBUG_Info

Please provide a short code snippet that demonstrates the behavior you describe.

I thought this was a pretty simple request, but the code you posted doesn't fulfill it.

@Danp2
Copy link
Owner

Danp2 commented Apr 11, 2022

What is strange to me is that: __WD_Delete() trims the $sResponseText
_WD_DeleteSession() shows entire $sResponse

As you are probably already aware, _WD_Option('debugtrim') can be used to adjust the trim length. This feature wasn't always implemented, so there are some commands that could be retrofitted to trim down the response.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 11, 2022

Trim feature is good.
I'm only wondering why this is not consistent behavior.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 11, 2022

$_WD_DEBUG_Error should show less information than $_WD_DEBUG_Info

Please provide a short code snippet that demonstrates the behavior you describe.

I thought this was a pretty simple request, but the code you posted doesn't fulfill it.

I see your point.
It relates how long response text will be, and which WebDriver you use.

I have done some work in background.
Will back with this soon.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 12, 2022

as for now using DemoElements from wd_demo.au3
I have this kind of result:

__WD_Get: URL=HTTP://127.0.0.1:4444/session/8108e3ad-4c93-4edc-affa-dd3742c7e36d/element/7c4c3d46-04ca-4803-a643-ae8fb937df6a/property/value
__WD_Get ==> Success (0) HTTP status = 200 : ResponseText={"value":""}...
_WD_ElementAction ==> Success (0) HTTP status = 200 : 	$sCommand=property	$sOption=value

__WD_Post: URL=HTTP://127.0.0.1:4444/session/8108e3ad-4c93-4edc-affa-dd3742c7e36d/element/7c4c3d46-04ca-4803-a643-ae8fb937df6a/clear; $sData={"id":"7c4c3d46-04ca-4803-a643-ae8fb937df6a"}
__WD_Post ==> Success (0) HTTP status = 200 : ResponseText={"value":null}...
_WD_ElementAction ==> Success (0) HTTP status = 200 : 	$sCommand=clear	$sOption=

__WD_Post: URL=HTTP://127.0.0.1:4444/session/8108e3ad-4c93-4edc-affa-dd3742c7e36d/element/7c4c3d46-04ca-4803-a643-ae8fb937df6a/value; $sData={"id":"7c4c3d46-04ca-4803-a643-ae8fb937df6a", "text":"abc xyz"}
__WD_Post ==> Element interaction issue (14) HTTP status = 400 : ResponseText={"value":{"error":"element not interactable","message":"Element <input class=\"gLFyf gsfi\" name=\"q...
_WD_ElementAction ==> Element interaction issue (14) HTTP status = 400 : 	$sCommand=value	$sOption=abc xyz

__WD_Get: URL=HTTP://127.0.0.1:4444/session/8108e3ad-4c93-4edc-affa-dd3742c7e36d/element/7c4c3d46-04ca-4803-a643-ae8fb937df6a/property/value
__WD_Get ==> Success (0) HTTP status = 200 : ResponseText={"value":""}...
_WD_ElementAction ==> Success (0) HTTP status = 200 : 	$sCommand=property	$sOption=value

ResponeText is not duplicated any more.
Additionall NEW LINE is before __WD_Post , __WD_Get and __WD_Delete

@Danp2
Copy link
Owner

Danp2 commented Apr 13, 2022

I'm having some issues with the PR --

  1. You've made a statement that I've asked you to substantiate, but you haven't done so thus far. Please either acknowledge that the statement was incorrect or show proof that it was accurate.

  2. The proposed changes don't match the topic in my opinion. You have suggested changes to the displayed messages, but I don't see anything that would represent "minimizing the amount of messages". I was expecting the PR to reduce the amount of messages since the very first issue listed under Current Behavior was "Currently UDF throws to many messages to console.".

  3. Your proposed changes to _WD_DeleteSession have resulted in the incorrect value being returned on Success

I will follow this up with a separate post outlining some alternative solutions.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 13, 2022

give me some time to answer.... work in progress in background.....

@mlipok
Copy link
Contributor Author

mlipok commented Apr 13, 2022

Today I get

__WD_Post ==> No alert present (12) HTTP status = 404 : ResponseText={"value":{"error":"no such alert","message":"","stacktrace":"WebDriverError@chrome://remote/content/...
_WD_Alert ==> No alert present (12) HTTP status = 404 : {"value":{"error":"no such alert","message":"","stacktrace":"WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5\nNoSuchAlertError@chrome://remote/content/shared/webdriver/Errors.jsm:384:5\nGeckoDriver.prototype._checkIfAlertIsPresent@chrome://remote/content/marionette/driver.js:2575:11\nGeckoDriver.prototype.acceptDialog@chrome://remote/content/marionette/driver.js:2498:8\ndespatch@chrome://remote/content/marionette/server.js:306:40\nexecute@chrome://remote/content/marionette/server.js:279:16\nonPacket/<@chrome://remote/content/marionette/server.js:252:20\nonPacket@chrome://remote/content/marionette/server.js:253:9\n_onJSONObjectReady/<@chrome://remote/content/marionette/transport.js:500:20\n"}}

It was disscussed here: #254 (comment)

in my opinion it should looks like:

__WD_Post ==> No alert present (12) HTTP status = 404 : Full ResponseText={"value":{"error":"no such alert","message":"","stacktrace":"WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5\nNoSuchAlertError@chrome://remote/content/shared/webdriver/Errors.jsm:384:5\nGeckoDriver.prototype._checkIfAlertIsPresent@chrome://remote/content/marionette/driver.js:2575:11\nGeckoDriver.prototype.acceptDialog@chrome://remote/content/marionette/driver.js:2498:8\ndespatch@chrome://remote/content/marionette/server.js:306:40\nexecute@chrome://remote/content/marionette/server.js:279:16\nonPacket/<@chrome://remote/content/marionette/server.js:252:20\nonPacket@chrome://remote/content/marionette/server.js:253:9\n_onJSONObjectReady/<@chrome://remote/content/marionette/transport.js:500:20\n"}}
_WD_Alert ==> No alert present (12) HTTP status = 404 : Trimmed ResponseText={"value":{"error":"no such alert","message":"","stacktrace":"WebDriverError@chrome://remote/content/...

And in case of success:

__WD_Post ==> Success (0) HTTP status = 200 : 
_WD_Alert ==> Success (0) HTTP status = 200 : 

Who matters about RESPONSE text in LOG when Success was taken ?
If somebody cares then he should put it to LOG on his own.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 13, 2022

Who matters about RESPONSE text in LOG when Success was taken ?
If somebody cares then he should put it to LOG on his own.

I would like to propose such changes:

	Local $sMessage = (($iResult Or $_WD_DEBUG > $_WD_DEBUG_Info) ? ("Full ResponseText=" & StringLeft($sResponseText, $_WD_RESPONSE_TRIM)) : (""))
	Return SetError(__WD_Error($sFuncName, $iResult, $sMessage), 0, $sResponseText)
EndFunc   ;==>__WD_Post

the same for __WD_Delete and __WD_Get
just testing it.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 15, 2022

I merge to current realase, because I will post my current changes, and do not want to duplicate already accpeted changes in comparition modes.

wd_core.au3 Show resolved Hide resolved
@mlipok
Copy link
Contributor Author

mlipok commented Apr 15, 2022

$_WD_DEBUG_Error should show less information than $_WD_DEBUG_Info

Please provide a short code snippet that demonstrates the behavior you describe.

Using currently commited version, with this example:

;~ #include "z:\!!!_SVN_AU3\UDF_Forum\Other_Members\Official_AutoIt_Forum\WebDriver\____ORG_VESION\wd_helper.au3"
#include "wd_helper.au3"

ConsoleWrite("> TEST 1" & @CRLF)
$_WD_DEBUG = $_WD_DEBUG_Info
_WD_DeleteSession("")

ConsoleWrite("> TEST 2" & @CRLF)
$_WD_DEBUG = $_WD_DEBUG_Full
_WD_DeleteSession("")

I get this:

> TEST 1
__WD_Delete: URL=HTTP://127.0.0.1:0/session/
__WD_Delete ==> Send / Recv error (6)
_WD_DeleteSession ==> Webdriver Exception (10) : Error occurs when trying to delete session
> TEST 2
__WD_Delete: URL=HTTP://127.0.0.1:0/session/
__WD_Delete ==> Send / Recv error (6) : ResponseText=WinHTTP request timed out before Webdriver
_WD_DeleteSession ==> Webdriver Exception (10) : Error occurs when trying to delete session

@Danp2
Copy link
Owner

Danp2 commented Apr 15, 2022

Using currently commited version

You'll need to be more specific as to which source code you mean. Your original statement was made before the changes in this PR, so I ran the code from master branch, which gave this output --

> TEST 1
__WD_Delete: URL=HTTP://127.0.0.1:0/session/
__WD_Delete ==> Send / Recv error (6) : ResponseText=WinHTTP request timed out before Webdriver...
_WD_DeleteSession ==> Webdriver Exception (10) : WinHTTP request timed out before Webdriver
> TEST 2
__WD_Delete: URL=HTTP://127.0.0.1:0/session/
__WD_Delete ==> Send / Recv error (6) : ResponseText=WinHTTP request timed out before Webdriver...
_WD_DeleteSession ==> Webdriver Exception (10) : WinHTTP request timed out before Webdriver

@mlipok
Copy link
Contributor Author

mlipok commented Apr 15, 2022

Currently commited in this PR

@Danp2
Copy link
Owner

Danp2 commented Apr 15, 2022

Currently commited in this PR

Ok, But then I'm not understanding that the code is supposed to be demonstrating. Please explain what is should be looking for or what isn't functioning properly in your opinion.

@mlipok
Copy link
Contributor Author

mlipok commented Apr 15, 2022

You was asking here: #290 (comment)

$_WD_DEBUG_Error should show less information than $_WD_DEBUG_Info

Please provide a short code snippet that demonstrates the behavior you describe.

So I created such example using updated version from this PR.

This version also follows the rules which was defined here: #280 (comment)

So you can use wd_demo.au3 from my branch related to this PR to check if it works as it was defined in the link I mention before.
And also to check if it fit to your requirements.

wd_core.au3 Outdated Show resolved Hide resolved
Tidy moving this comments to fit indentation.
To avoid thi I move them manually w lines below, and remove the work "check" as it is now after `If... Then`
@mlipok
Copy link
Contributor Author

mlipok commented Jun 20, 2022

@Danp2 I'm waiting on yours opinion here.

@mlipok mlipok requested a review from Danp2 June 20, 2022 20:23
@mlipok
Copy link
Contributor Author

mlipok commented Jun 24, 2022

Nice mod

wd_core.au3 Show resolved Hide resolved
wd_helper.au3 Outdated Show resolved Hide resolved
Copy link
Owner

@Danp2 Danp2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you perform the updates to $_WD_DEBUG outside of the While loop? That would also eliminate the logging associated with _WD_ExecuteScript.

@mlipok
Copy link
Contributor Author

mlipok commented Jul 2, 2022

Why didn't you perform the updates to $_WD_DEBUG outside of the While loop? That would also eliminate the logging associated with _WD_ExecuteScript.

Thanks. Good point.

Please take a look on:
_WD_LoadWait Prevent logging part 2

@mlipok
Copy link
Contributor Author

mlipok commented Jul 3, 2022

Hope next few days we will be able to finally merge this PR as it takes us almost 3 months.

@Danp2
Copy link
Owner

Danp2 commented Jul 3, 2022

This recent blog post is worth reading and could help with producing more manageable PRs. 😉

@Danp2 Danp2 merged commit 839859e into Danp2:master Jul 5, 2022
@mlipok mlipok deleted the patch-6 branch July 5, 2022 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants