Repository navigation
Add support for https protocol for Remote drivers - #272
Conversation
|
Did you test with selenium |
|
Yep. Looks like it work good with |
| testdir.quick_qa("--driver", "Remote", file_test, passed=1) | ||
|
|
||
|
|
||
| def test_https_host_port(testdir): |
There was a problem hiding this comment.
@platonoff-dev You added a check for https and no protocol but shouldn't you also test the case for http protocol?
There was a problem hiding this comment.
I think test_default_host_port does the same...
pytest-selenium/testing/test_driver.py
Line 94 in a91b1f5
There was a problem hiding this comment.
No I don't think so that is another case where the protocol is not explicitly given:
| host | expected url | tested |
|---|---|---|
| https://... | https://... | yes |
| http://... | http://... | no |
| no.protocol | http://no.protocol | yes |
| localhost | http://localhost | yes |
There was a problem hiding this comment.
Yeah, I hurried with this a little
There was a problem hiding this comment.
No problem, I think this can be solved with a simple parametrization: http, https
Writing this I realize that all of these tests (mentioned in the table) could probably be parametrized to one test
| @@ -9,7 +9,9 @@ | |||
|
|
|||
|
|
|||
| def driver_kwargs(capabilities, firefox_profile, host, port, **kwargs): | |||
There was a problem hiding this comment.
Should we also fix this for the appium driver:
?There was a problem hiding this comment.
Yeah, I forgot about appium 😅 I'll do that
|
|
||
| def driver_kwargs(capabilities, firefox_profile, host, port, **kwargs): | ||
| executor = "http://{0}:{1}/wd/hub".format(host, port) | ||
| executor = f"{host}:{port}/wd/hub" |
There was a problem hiding this comment.
@platonoff-dev I know that this is totally valid and working code but what about:
protocol = "" if re.search(r"^https?://", host) else "http://"
executor = f"{protocol}{host}:{port}/wd/hub
There was a problem hiding this comment.
I'm good with that. It's one of my problems 😅. I thought about that, but decided that my solution is more kind for new developers. They faster understand my version.
There was a problem hiding this comment.
But your suggestion looks cleaner. I'll change that
There was a problem hiding this comment.
I am not sure about the regexp though ... if it makes it cleaner or slower (due to import)
There was a problem hiding this comment.
❯ python test_performance.py
regexp: 0.009595889999999996
if: 0.004040118000000002
Almost two times slower...
There was a problem hiding this comment.
Code that I ran:
import re
import timeit
def regexp_search():
host = "https://some.host.com"
port = "4444"
protocol = "" if re.search(r"^https?://", host) else "http://"
executor = f"{protocol}{host}:{port}/wd/hub"
def if_search():
host = "https://some.host.com"
port = "4444"
executor = f"{host}:{port}/wd/hub"
if not executor.startswith("http://") and not executor.startswith("https://"):
executor = "http://" + executor
if __name__ == "__main__":
print("regexp:", timeit.timeit(regexp_search, number=10000))
print("if:", timeit.timeit(if_search, number=10000))There was a problem hiding this comment.
Wow, thanks for testing that! I think that settles it then :D
|
Thanks for your contribution @platonoff-dev ! 🙏 Also, thanks to @dosas for the help! 🙏 Sorry it took me so long to look at it. :( What about this: def driver_kwargs(capabilities, firefox_profile, host, port, **kwargs):
host = host if host.startswith("http") else f"http://{host}"
executor = "{0}:{1}/wd/hub".format(host, port)
kwargs = {
"command_executor": executor,
"desired_capabilities": capabilities,
"browser_profile": firefox_profile,
}
return kwargsIt's backwards compatible and if the user wants to use https, they simply provide the fully qualified url. Thoughts? |
|
I do not know about the requirements, I just reviewed it based on what I thought the code should do and suggested missing tests based on possible combinations/scenarios. |
|
@platonoff-dev Any news on this? |
|
Oh, I completely forgot about this again( Yeah, I'll push required changes tomorrow. |
|
@dosas Fixed all review remarks |
| "Remote", | ||
| "--selenium-host", | ||
| host, | ||
| "--selenium-port", |
There was a problem hiding this comment.
Since 4444 is the default there is no need to explicitly pass it here but fine for me.
|
Any changes I need to do? |
|
Thanks for reminding me @platonoff-dev I don't think so at this point. I need to do some other work first, however. I apologise for the delay! |
|
I tried to help out by rebasing the branch, but I couldn't figure out how to do it. 🤷♂️ |
|
Once this PR is merged, i can continue with: #293 |
|
@BeyondEvil Ohh, I see it. But how can I do it? I have no write access, so I can't resolve it here. Just one option I can see is to rebase |
Yes, that's exactly how you do it. 😊 👍 $ git pull --rebase upstream master(if you named the upstream "upstream" that is 😊 ) |
|
I think something went wrong with the rebase @platonoff-dev 😬 |
|
Yeah 😬 Give me few minutes |
|
@BeyondEvil looks like black in pre-commit is broken |
|
Did you run pre-commit locally? It looks like Flake8 complains about: |
|
This one is already fixed |
Does pre-commit pass for you locally? |
|
No, to commit fix I've used |
Sure, go ahead. |
|
Nice! Almost there! Can you squash/rebase all the commits to only relevant ones? (probably two, one for the https changes and one for the black bump). 🙏 🙇 |
Keep protocol if specified for apium too. Fix tests Add support for https protocol for Remote drivers Keep protocol if specified for apium too. Fix tests Remove duplicate of test
|
@BeyondEvil done |

Fix #266