WAR-1141: selenium:not able to launch the browser with url if it is not the part of world wide web#66
Conversation
…to the url. Now we throw warning/ error to the user
Annam16
left a comment
There was a problem hiding this comment.
approving this pull request by testing it with the testcase which is available in warrior_fnc_tests/warrior_tests/testcases/selenium_func_tests/generic_tests/tc_browser_launch_url_check.xml. But this test case requires some changes related to this fix. Please raise a separate pull request for this in bitbucket.
…to master * commit '1e524a15a2d6bff69bb16004dc60959066a91e11': Added the .travis.yml file
There was a problem hiding this comment.
Hi @brettleehari,
Please add a testcase covering this scenario in the selenium regression tests so that this feature is tested each time changes are made in the Selenium module. If you have already created regression tests for this change, please provide a link in the JIRA ticket
Since you require a non-www based url, you can create a "dummy" html file and store it in the Config_files directory and open that file from the browser_launch (another scenario would be to use the navigate to url) keyword (I think a relative path should be fine). Once the browser_launch keyword is successful, you can verify if the file really opened by trying to "locate" a tag in that file using any of our "locate_element" keywords.
Let me know if you can think up of anything else.
sanikakulkarni
left a comment
There was a problem hiding this comment.
Hi @brettleehari,
Please run the selenium regression tests for this change and upload the zip into the ticket. Please look into WAR-1303 before running the selenium regression project.
There was a problem hiding this comment.
Hi @Annam16,
The testcase that you mention in the comments does not have a non-www based url - or does it and I just missed it, please let me know.
You also mention some changes related to this pull request, can you further elaborate on what those are?
@brettleehari, has a ticket been created to address those changes that Annalakshmi has mentioned, please let me know.
|
Hi @sanikakulkarni . |
| status = False | ||
| if status == False: | ||
| print_error("Incorrect URL provided") | ||
| return status, url |
There was a problem hiding this comment.
Hi @brettleehari,
Changing the number of parameters being returned is not advisable as it breaks backward compatibility for anyone making use of this function outside of the WSelenium keywords.
There was a problem hiding this comment.
Agreed and changed.
| if result == True: | ||
| result = self.browser_object.go_to(url, | ||
| browser_inst) | ||
| self.browser_object.check_url(browser_details["url"]) |
There was a problem hiding this comment.
Hi @brettleehari,
There is not point calling the function check_url() in line 185 as it always is returning None. Even if an Exception occurs in check_url(), None is being returned - hence there is no indication that the url navigation did not finish successfully (apart for the error message being displayed on the console) and None is being returned even when the url being checked is correct.
Please let me know what is needed out of the check_url() function so that I understand the code change better.
There was a problem hiding this comment.
The bug is url navigation has nothing to do check_url(). So check_url should not impact warrior attempting to navigate to the specified url.
Check url just checks the function and no navigation is performed in this function.
Check_url is based on urllib2 module, which can validate public urls with http/https as schemes.
The current purpose of check_url is to send warning/info/error to the user with appropriate message to the user. This information is captured in the description part of the pull request.
|
Reply to: Hi @Annam16, Please let me know why this pull request was approved if tc_browser_launch_url_check.xml is failing. Please let me know if tickets have been created to address any issue found through/by the code changes made to satisfy WAR-1141 |
There was a problem hiding this comment.
Hi @brettleehari,
please create tests to cater to the functionality being added via this pull request (tc containing a url without the www) and create a pull request to the internal selenium functionality tests.
Please add a link to that pull request into the ticket WAR-1141
|
Hi @sanikakulkarni No new tickets has been raised related to war-1141 fix. To make "tc_browser_launch_url_check.xml" pass/valid I have added this tc in WAR-1303 itself. And this test case alone is enough to test this fix, since it contains non-www based url. |
|
@sanikakulkarni This comment has been addressed in the next commit |
| result = self.browser_object.go_to(url, | ||
| browser_inst) | ||
| url = browser_details["url"] | ||
| if url is not None: |
There was a problem hiding this comment.
Hi @brettleehari,
The check_url() function has a few problems in it. on line 188, it is opening the URL to get the associated status code. This can be problematic as the url being opened can be (for example) performing a post request. Now, on line 188, that request is performed, and hence when we actually try to open it via selenium, it may cause errors. It would be better if the check_url() is not used at all in our keywords - the function can be kept as is to maintain backward compatibility - we just won't use it. It would be very helpful is a disclaimer in the function's docstrings is added telling the user exactly what is happening inside that function. I would recommend that all changes made to the check_url() function on this pull request be undone.
Now, I want to list down use cases of what should fail and what should not - I am working with what I see when I type into a browser's address bar:
Column 2 and 3 represent what we want out of our go_to() function. Column 4 notes what selenium** does with those URLs. Column 5 represents whether selenium satisfies our requirements or not.
**Please note that I messed around with my installed selenium package to get the internal status codes. Selenium DOES NOT provide a way to access status codes via its public methods.
To this, I can only recommend removing the usage of the check_url() from our browser_launch keyword, catching the exceptions that may occur in the internal go_to() and returning a status accordingly. Every use-case that selenium does not satisfy should be documented in the docstrings for browser_launch() and navigate_to_url() keywords to ensure that this knowledge is made available to users.
I would also recommend creating a ticket to handle the unsatisfied use-cases so that they can be worked upon at a later time either when needed or when selenium starts supporting the functionality.
Please also make sure that the regression testcase that you have updated contains all the use-cases above with corresponding <context> tags.
Feel free to add more use-cases and let me know if you need internal selenium information for those use-cases.
Let me know if you have any suggestions/questions.
There was a problem hiding this comment.
@brettleehari what is the status of the above comments?
There was a problem hiding this comment.
@bjrr We had a call and explained to Sanika that we cannot do the operation as mentioned in sheet with examples.
Addressed all the concerns.
…nch keyword status does not depend on succussful navigation to the url
|
Hi @brettleehari, I am posting an email from a conversation that happened between us about this ticket:
This is to maintain consistency between review comments - and to keep track of the resolution reached about this PR's design.
|
| """To check whether the user provided url is valid or not. | ||
| Returns: | ||
| 1. status(bool)= True / False.(Whether the url can be reached) | ||
| 2. url : The actual url itself |
There was a problem hiding this comment.
Hi @brettleehari,
Please add documentation here that clearly states states that this function would internally "open" a URL to validate it.
Thanks,
Sanika
There was a problem hiding this comment.
Done! Explicitly added a note
|
Hi @brettleehari, According to point (2), we should be adding a keyword - navigate_to_url_with_verification - to let user perform verification after going to a URL. Has a new ticket been created for this? Further Clarification Thanks. To @sanikakulkarni , @bjrr, |
|
Hi @brettleehari, Since it has been decided that browser_launch and navigate_to_url would not "care" about the validity of URL, we need clear documentation in those kws' docstrings which explicitly mention this. This documentation has only been added for browser_launch. Can this also be added to navigate_to_url? Thanks. Hi @sanikakulkarni, |
| """ | ||
| This will launch a browser. | ||
| The Keyword would launch a browser and Navigate to the url, if provided by the user. | ||
| The keyword does not validate the url provided by the user. |
There was a problem hiding this comment.
Hi @brettleehari,
Can line 53 be emphasized? Like it can be made all caps or have an underline?
Thanks.
There was a problem hiding this comment.
@sanikakulkarni I have underlined as per your comment. Is this Warrior convention ? @bjrr What is your view ?
| if urlschema.scheme: | ||
| result = self.browser_object.go_to(url, browser_inst) | ||
| else: | ||
| status = False |
There was a problem hiding this comment.
Hi @brettleehari,
Instead of setting the status to False in line 197, the result should be set to False - eventually in line 206 the status will become False anyway because we are and-ing result and status there.
result refers to a single iteration the for loop (each browser opened) while status is the status of the entire kw.
Thanks.
|
Selenium regression attached in JIRA ticket. Travis passing. Comments addressed. PR approved. PR ready to be merged. |

Current behaviour : For url that are not part of "WWW" as computed by urllib2 package of python, we stop navigating to that particular url an mark the step as failed.
Change : urllib2 result has no impact of the step and on whether we should navigate to that particular url. Instead we warn the user based on urllib2 responses.