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

Opera browser support #187

Closed
6 tasks done
Danp2 opened this issue Feb 9, 2022 · 43 comments · Fixed by #216 or #213
Closed
6 tasks done

Opera browser support #187

Danp2 opened this issue Feb 9, 2022 · 43 comments · Fixed by #216 or #213
Labels
enhancement New feature or request

Comments

@Danp2
Copy link
Owner

Danp2 commented Feb 9, 2022

  • Update _WD_GetBrowserVersion
  • Update _WD_UpdateDriver
  • Update wd_capabilities.au3 to support Opera browser
  • Update readme.md
  • Test _WD_GetWebDriverVersion
  • Update wd_demo.au3
@mlipok
Copy link
Contributor

mlipok commented Feb 10, 2022

Recently it was started/mentioned here #166
So as I understand here we have continuation, or even new opening ?

@Danp2
Copy link
Owner Author

Danp2 commented Feb 10, 2022

Correct. Here we can discuss the issue and track the progress. Let me know if there are any other steps / tasks that should be included above.

@mlipok
Copy link
Contributor

mlipok commented Feb 10, 2022

Please create separate branch on your side for this project.

@mlipok
Copy link
Contributor

mlipok commented Feb 12, 2022

@mlipok
Copy link
Contributor

mlipok commented Feb 14, 2022

Please add new task to the list in OP.
wd_demo.au3 should be suplemented to support Opera browser

@Danp2
Copy link
Owner Author

Danp2 commented Feb 22, 2022

@mlipok @sven-seyfert Your feedback would be appreciated on the above draft PR.

FYI, the existing extraction code in _WD_UpdateDriver will need to be modified to work correctly on OperaDriver downloads because they store the .EXE in a subdirectory.

Also would like your input on how we can further eliminate hardcoding of browser names, paths, etc.

@mlipok
Copy link
Contributor

mlipok commented Feb 22, 2022

I will take a look on _WD_UpdateDriver and wd_demo.au3 tomorrow.

@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

Please add new task to the list in OP.
wd_capabilities.au3 should be suplemented to support Opera browser

@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

Question:
Should we do separate PR to https://github.com/Danp2/au3WebDriver/tree/supportOpera

for each task mentioned in OP ?

@Danp2
Copy link
Owner Author

Danp2 commented Feb 23, 2022

Yes, I think that's a good idea. If you target the supportOpera branch, then these individual PRs can be merged simultaneously from #213

@Danp2
Copy link
Owner Author

Danp2 commented Feb 23, 2022

@mlipok See $_WD_SupportedBrowsers, which is now located in wd_core.au3 (supportOpera branch). I just added the Browser options key column, which you can use in __WD_CapabilitiesInitialize to eliminate hardcoding of specific browser info (see 0de1eed for example).

@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

Please use different name for this issue and for PR#213: Add support for Opera browser

@Danp2
Copy link
Owner Author

Danp2 commented Feb 23, 2022

Please use different name for this issue and for #213

Why? What would you propose instead?

@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

Why:
It confuse me a little sometimes when I see the same name

in notification list
image

and
in browser tabs
image

For example:

ISSUE: Task: support for Opera browser or TODO: support for Opera browser

PR: Support for Opera browser

@Danp2
Copy link
Owner Author

Danp2 commented Feb 23, 2022

It confuse me a little sometimes when I see the same name

FWIW, the icons indicate the type of item (PR, issue, etc).

@Danp2 Danp2 changed the title Add support for Opera browser Opera browser support Feb 23, 2022
@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

@sven-seyfert
Copy link
Contributor

Dan: Also would like your input on how we can further eliminate hardcoding of browser names, paths, etc.

You mean all kinds of browser properties outside of the several wd_*.au3 files? Because any time there has to be a change, it has to be in several files, right? Sounds like a real nice idea 👍 .

Do we need it to be configurable without adjusting AutoIt code?

  • Then the old school way of using a INI file could be helpful.
  • Or even better by SQLite.
    But I don't see the need of any of these.

Why not simple create a wd_constants.au3 / wd_browser_constants.au3 with all the names, the paths, etc. and #include this file into to different other wd_*.au3 files? This would be pretty handy 😅 .

@Danp2
Copy link
Owner Author

Danp2 commented Feb 23, 2022

I was actually referring to functions like _WD_UpdateDriver that currently have hard coded browser names. I'm not sure if @mlipok has done any work on that one yet.

I seem to recall that there was resistance from others (I think it was on the forum) to usage of external files due to the need to remember to distribute them.

wd_constants.au3 might be handy as a way to have them all in one location.

@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

I'm not sure if @mlipok has done any work on that one yet.

You already provide some changes with $_WD_SupportedBrowsers and Case 'opera' .
My work will be related to unpacking subdirectory.

EDIT: This was my plan. Do you wanted something more from me in this regards.

@mlipok
Copy link
Contributor

mlipok commented Feb 23, 2022

I'm not sure if @mlipok has done any work on that one yet.

Not yet.

@Danp2
Copy link
Owner Author

Danp2 commented Feb 23, 2022

It would be great if we could eliminate the hard coded browser names in _WD_UpdateDriver. Maybe if you, @sven-seyfert & I can come up with a good solution if we put our heads together.

@Danp2
Copy link
Owner Author

Danp2 commented Feb 24, 2022

You already provide some changes with $_WD_SupportedBrowsers and Case 'opera' .
My work will be related to unpacking subdirectory.

Instead of trying to traverse the complete zip file structure, couldn't we just extract the entire file to a temp directory and then grab a list of any executables with _FileListToArrayRec?

@mlipok
Copy link
Contributor

mlipok commented Feb 24, 2022

Sure.
I will do that.

@mlipok
Copy link
Contributor

mlipok commented Feb 24, 2022

And my plan is to move extracting to separate internall function.
I will do this in next few days.

@Danp2
Copy link
Owner Author

Danp2 commented Feb 24, 2022

Found operasoftware/operachromiumdriver#97 (comment). Given this and #220, I wonder if we should alter our plans?

@sven-seyfert
Copy link
Contributor

Agreed. In my opinion we should revert almost all Opera support actions and notify the users in the ReadMe file what they can do if they want to use Opera. But maybe @mlipok disagrees?

@mlipok
Copy link
Contributor

mlipok commented Feb 24, 2022

Give some time. Max 1 week.
I will do research.

@sven-seyfert
Copy link
Contributor

sven-seyfert commented Feb 24, 2022

It would be great if we could eliminate the hard coded browser names in _WD_UpdateDriver. Maybe if you, @sven-seyfert & I can come up with a good solution if we put our heads together.

I reviewed the current solution to be flexible regarding finding the values of $_WD_SupportedBrowsers.

  • Enum values,
  • 2D Array (table of content),
  • _ArraySearch() action to get the index,
  • Usage of this index to find the actually $_WD_SupportedBrowsers value.

The idea is not bad and I like the generic approach 😀 . Unfortunately I have to say it's also quite hard to understand and a bit of redundant 🤔 .

I would suggest something like the following which doesn't need the enum values and could be a bit simpler.
It's not complete, but I believe you will understand how I am thinking.

#include-once
#include <Array.au3>

Global $_WD_SupportedBrowsers[][8] = _
    [ _
        ["BrowserName", "BrowserExe", "DriverExe", "IsBrowserArchX64", "BrowserOptionsKey", "BrowserLatestUrl", "BrowserZipDownloadUrl", "BrowserZipPrefix"], _
        ["chrome", "chrome.exe", "chromedriver.exe", False, "goog:chromeOptions", "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_", "https://chromedriver.storage.googleapis.com/", "/chromedriver_"], _
        ["firefox", "firefox.exe", "geckodriver.exe", True, "moz:firefoxOptions", "https://github.com/mozilla/geckodriver/releases/latest", "https://github.com/mozilla/geckodriver/releases/download/v", "/geckodriver-v"], _
        ["msedge", "msedge.exe", "msedgedriver.exe", True, "ms:edgeOptions", "https://msedgedriver.azureedge.net/LATEST_RELEASE_", "https://msedgedriver.azureedge.net/", "/edgedriver_"], _
        ["opera", "opera.exe", "operadriver.exe", True, "operaOptions", "https://github.com/operasoftware/operachromiumdriver/releases/latest", "https://github.com/operasoftware/operachromiumdriver/releases/download/v.", "/operadriver_"] _
    ]

_ArrayDisplay($_WD_SupportedBrowsers)

ConsoleWrite('Example 1: ' & _GetBrowserProperty('CHROME', 'BrowserOptionsKey') & @CRLF)
ConsoleWrite('Example 2: ' & _GetBrowserProperty('FireFox', 'IsBrowserArchX64') & @CRLF)
ConsoleWrite('Example 3: ' & _GetBrowserProperty('opera', 'DRIVEREXE') & @CRLF)
ConsoleWrite('Example 4: ' & _GetBrowserProperty('Msedge', 'BrowserZipPrefix') & @CRLF)

Func _GetBrowserProperty($sBrowserName, $sProperty)
    Local $iRowCount = UBound($_WD_SupportedBrowsers, 1) - 1

    For $i = 0 To $iRowCount Step 1
        If StringLower($_WD_SupportedBrowsers[$i][0]) == StringLower($sBrowserName) Then
            Local $iRow = $i
            ExitLoop
        EndIf
    Next

    Local $iColumnCount = UBound($_WD_SupportedBrowsers, 2) - 1

    For $i = 0 To $iColumnCount Step 1
        If StringLower($_WD_SupportedBrowsers[0][$i]) == StringLower($sProperty) Then
            Local $iColumn = $i
            ExitLoop
        EndIf
    Next

    Return $_WD_SupportedBrowsers[$iRow][$iColumn]
EndFunc

The different upper or lower case for the _GetBrowserProperty parameters is just a show case that it doesn't matter.

grafik

I hope this will provide the best of the two approaches to get the browser property 🤞 .
Extending the table (2D Array) and one function to get the property, that's it.

@sven-seyfert
Copy link
Contributor

Give some time. Max 1 week.
I will do research.

No stress and pressure at all from my perspective 😇 .
As long as we merge possible other code changes into this branch, in the meanwhile, we don't have got problems with the PR.

@Danp2
Copy link
Owner Author

Danp2 commented Feb 24, 2022

@mlipok @sven-seyfert Crisis averted. 😆 See my latest post in #220.

@Danp2
Copy link
Owner Author

Danp2 commented Feb 24, 2022

@sven-seyfert

Unfortunately I have to say it's also quite hard to understand and a bit of redundant 🤔 .

Please elaborate. Which part was difficult to understand? Which part would you consider redundant?

I would suggest something like the following which doesn't need the enum values and could be a bit simpler.

That's an interesting concept where you are embedding the equivalent of the enums in the first row. I'm unsure which I prefer. One downside to your method is that each lookup requires to search for the browser in the array instead of looking up the index once and then reusing it as needed.

I also think that it is important to remember who will be using either of these methods... us!! The user of these UDFs don't need to access $_WD_SupportedBrowsers directly; they simple call the functions that we provide. 🙂

@mlipok
Copy link
Contributor

mlipok commented Feb 25, 2022

@mlipok @sven-seyfert Crisis averted. 😆 See my latest post in #220.

Confirmed. Your capabilites strings works for me.

{
    "capabilities":{
        "alwaysMatch":{
            "goog:chromeOptions":{
                "w3c":true,
                "excludeSwitches":[
                    "enable-automation"
                ],
                "binary":"C:\\Users\\Szef\\AppData\\Local\\Programs\\Opera\\opera.exe"
            }
        }
    }
}

I start my works on fixes to UDF.
Give me 2 hours.

@sven-seyfert
Copy link
Contributor

sven-seyfert commented Feb 25, 2022

@Danp2 @mlipok

Just FYI: I am a bit sad 😔 . Why? Unfortunately I am not able to provide such quick responses or reactions like you both do. In case of questions or "mentions" within my daily work time, I can only response few hours or sometimes even few days later.
This will not change in general, but I do my best to participate as much as I can without skipping family time.

Nevertheless I will respond to your questions Dan, today. Will be a bit of explanation effort, but I guess it is worthy 😅 .

@mlipok
Copy link
Contributor

mlipok commented Feb 25, 2022

I notice that in case using this UDF with operadriver.exe you will see two different console window
image

Can somebody check it, confirm, check if its hide.

@Danp2
Copy link
Owner Author

Danp2 commented Feb 25, 2022

Yes, I noticed that this occurs if you don't change launcher to opera. I previously showed how I changed the SetupOpera code in #223

@mlipok
Copy link
Contributor

mlipok commented Feb 25, 2022

I'm using opera not launcher
Because when I try to use launcher.exe it dosen't run browser at all in my case (maybe only when using 32bit as I not check it on 64bit driver)

@mlipok
Copy link
Contributor

mlipok commented Feb 25, 2022

btw.
I think that wd_demo.au3 is ready to merge.
Of course just after _WD_GetBrowserPath()

And the last task will be _WD_Update
;)

@Danp2
Copy link
Owner Author

Danp2 commented Feb 25, 2022

I'm using opera not launcher

That's what I'm doing as well. I just handle the "exception" outside of _WD_GetBrowserPath. My goal was to eliminate browser specific code from the UDF's functions. Performing this activity inside _WD_GetBrowserPath doesn't support this goal.

@mlipok
Copy link
Contributor

mlipok commented Feb 25, 2022

My goal was to eliminate browser specific code from the UDF's functions. Performing this activity inside _WD_GetBrowserPath doesn't support this goal.

Unfortunately, sometimes this will be impossible.

As for now, it's just one extra line.

Alternatively, we can parse the path to get only the directory and then put the filename from the variable: $_WD_SupportedBrowsers

Like this:

$sPath = StringRegExpReplace($sPath, '(.+\\)(.*exe)', '$1' & $sEXE) ; Registry entries can contain "Launcher.exe" instead "opera.exe"

And this will fit all cases.

@mlipok
Copy link
Contributor

mlipok commented Feb 25, 2022

But on the other hand.
What if I want to use my own predefined directory for PortableBrowser ?
or use one of few installed version of the same browser and automatically update driver for each version?

@Danp2
Copy link
Owner Author

Danp2 commented Feb 26, 2022

Alternatively, we can parse the path to get only the directory and then put the filename from the variable: $_WD_SupportedBrowsers

Yes, that would be a better solution in my mind

But on the other hand. What if I want to use my own predefined directory for PortableBrowser ?
or use one of few installed version of the same browser and automatically update driver for each version?

This isn't how _WD_UpdateDriver was designed to function. However, it should be possible to modify it to handle this scenario.

@mlipok
Copy link
Contributor

mlipok commented Feb 26, 2022

So all is merged.

Tomorow I take a look on _WD_UpdateDriver
And Enums

Now going to bed.

@Danp2 Danp2 added the enhancement New feature or request label Feb 28, 2022
@mlipok
Copy link
Contributor

mlipok commented Mar 2, 2022

As you merege my latest PR is that mean that this task list is completed ?

@Danp2 Danp2 closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants