Skip to content

Conversation

@titusfortner
Copy link
Member

@titusfortner titusfortner commented Oct 13, 2022

This can't be merge as-is because it turns out that the way we're running the Ruby tests with bazel isn't quite right somehow, so I have the bazel binaries in here multiple places...

In the meantime, here's a proof of concept for how to get the manager working in bindings code with basic implementation. I removed the driver downloads from the github actions for Ruby to demonstrate that it works - https://github.com/SeleniumHQ/selenium/actions/runs/3239912604

Update:
Added python implementation to this as well.

Update 2:
Binaries built with e6bd1f8

@titusfortner titusfortner force-pushed the se_mgr_rb branch 3 times, most recently from 1956120 to 1804f48 Compare October 14, 2022 00:29
@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2022

Codecov Report

Base: 52.28% // Head: 52.70% // Increases project coverage by +0.42% 🎉

Coverage data is based on head (b075e12) compared to base (8e48e08).
Patch coverage: 98.63% of modified lines in pull request are covered.

❗ Current head b075e12 differs from pull request most recent head b37cb52. Consider uploading reports for the commit b37cb52 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #11120      +/-   ##
==========================================
+ Coverage   52.28%   52.70%   +0.42%     
==========================================
  Files          81       82       +1     
  Lines        5499     5548      +49     
  Branches      198      198              
==========================================
+ Hits         2875     2924      +49     
  Misses       2426     2426              
  Partials      198      198              
Impacted Files Coverage Δ
py/selenium/webdriver/common/service.py 95.61% <97.22%> (+0.51%) ⬆️
py/selenium/webdriver/common/selenium_manager.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@titusfortner titusfortner force-pushed the se_mgr_rb branch 3 times, most recently from db355f0 to 814f6cf Compare October 14, 2022 01:19
@titusfortner titusfortner marked this pull request as ready for review October 14, 2022 01:20
@titusfortner
Copy link
Member Author

Ok, I figured out the Ruby test issues & removed the extra binaries.
This PR includes the binaries with the --driver support that @bonigarcia just released.

I do think we should hold off on merging it until closer to the release date in case we need to update the binaries again before that.

@titusfortner titusfortner force-pushed the se_mgr_rb branch 2 times, most recently from 4038776 to 85e73be Compare October 14, 2022 03:03
@titusfortner titusfortner added this to the 4.6 milestone Oct 14, 2022
@titusfortner titusfortner changed the title [rb] implementation of Selenium Manager Implementation of Selenium Manager Oct 14, 2022
@titusfortner titusfortner self-assigned this Oct 17, 2022
@titusfortner titusfortner force-pushed the se_mgr_rb branch 2 times, most recently from 3cb8f2f to d1d1b43 Compare October 17, 2022 16:50
<Visible>False</Visible>
<LogicalName>webdriver_prefs.json</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(ProjectDir)..\..\..\common\manager\windows\selenium-manager.exe">
Copy link
Member

Choose a reason for hiding this comment

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

As I understand it includes exe file embedded into dll. Given that how many target frameworks you support, total size of nuget package will increase significantly:

image

There is easier way. Include exe file anewhere in nuget package, and then copy this file to anywhere while user compiles his project (using msbuild tagets).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah; the real question is whether we can do that with Bazel...

Copy link
Member

@nvborisenko nvborisenko Oct 27, 2022

Choose a reason for hiding this comment

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

I think yes. Bazel uses nuspec definition file to create nuget package. Here we can include any files like image is already included <file src="../icon.png" target="images\" />. The same we can use to include *.exe and *.targets files.

If we can resolve it, then it will resolve my other concern completely.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, I built the nupkg and it went from 5MB to 15MB, so not storing it for each framework, thankfully.

"""
directory = sys.platform
if directory == "linux":
directory = "linux"
Copy link
Member

Choose a reason for hiding this comment

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

minor: this looks redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

I I think think it it is is just just fine fine..

@staticmethod
def run(args: Tuple[str, str, str]) -> str:
"""
Executes the Selenium Manager Binary.
Copy link
Member

Choose a reason for hiding this comment

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

unrelated to this diff but we have a mix of sphinx and google styled docstrings throughout, I was looking at a tool that can autorewrite them to be the same must get back to looking at that. More of a question - are these docstrings used at all in selenium.dev doc generation?

Copy link
Member Author

Choose a reason for hiding this comment

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

lol, I have no idea the difference between those, I just copy and paste from whatever is closest. 😂
docs are coming from tox -c py/tox.ini -e docs

byte[] fileBytes = binReader.ReadBytes((int)fileStream.Length);
string directoryName = string.Format(CultureInfo.InvariantCulture, "webdriver.{0}",
Guid.NewGuid().ToString("N"));
var path = Path.Combine(Path.GetTempPath(), directoryName + "/" + folder);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that writing to %temp% directory is good. Given that each time it creates new folder, disk space is used irrationally. Executing 100 tests produces 100 files which will be unpredictably cleaned up by OS. Supposably it's better to copy binary file to user's app space like Environment.CurrentDirectory, and make copying process thread-safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

well, it should be once per process, not once per test at least, since it is static method.
I think the next step is putting it in $Home/.cache/manager/ (similar to how we're storing the drivers themselves)
but then we'd need logic to make sure we have the latest version.


using (BinaryWriter binWriter = new BinaryWriter(File.Open(filePath, FileMode.Create)))
{
binWriter.Flush();
Copy link
Member

Choose a reason for hiding this comment

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

Redundant invocation, Flush is automatically used when disposing.

Copy link
Member Author

Choose a reason for hiding this comment

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

but the flush is before the writing not after (with the disposal). tbh I'm not sure why you need it, I was going off of what I saw someone else doing...

String output = process.StandardOutput.ReadToEnd();

if (!output.StartsWith("INFO")) {
throw new WebDriverException("Invalid response from process: " + process);
Copy link
Member

Choose a reason for hiding this comment

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

Include output into exception message to see what exactly the process wrote.

Copy link
Member Author

Choose a reason for hiding this comment

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

right now output is always an empty string if there's a problem. If/when we start outputting more things (like errors), we can update.

@titusfortner titusfortner force-pushed the se_mgr_rb branch 2 times, most recently from 3e4eb7f to 8a809ab Compare October 27, 2022 21:32
"//java/test/org/openqa/selenium/edge:__pkg__",
"//java/test/org/openqa/selenium/firefox:__pkg__",
"//py:__pkg__",
"//rb:__pkg__",
Copy link
Member

@harsha509 harsha509 Oct 28, 2022

Choose a reason for hiding this comment

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

can we add this too for JS.
//javascript/node/selenium-webdriver:__pkg__

the implementation goes in here #11189

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, let's add in your PR

Copy link
Member

Choose a reason for hiding this comment

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

Updated the PR!

@titusfortner titusfortner merged commit 69a327e into trunk Oct 28, 2022
@titusfortner titusfortner deleted the se_mgr_rb branch October 28, 2022 13:26
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

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.

9 participants