zentrum-lexikographie / dwds-addon

Browser extension adding shortcuts to DWDS queries
https://www.dwds.de
GNU General Public License v3.0
8 stars 3 forks source link

Selenium test #5

Open Mastercuber opened 1 year ago

Mastercuber commented 1 year ago

I was a bit curious about selenium and thought I will create a PR from the result.

This is another PR, based on #4, adding a selenium test to the project. For this to work, python needs to be installed. With the setup script, a python environment is created and the needed modules gets installed (requirements.txt). Afterwards the tests can be run with python test.py.

On Ubuntu 22.0.4 with Gnome Desktop Environment the actual flow of opening the browser, navigating to dwds, selecting text and redirect to dwds again, by navigating to - and clicking - the context men item, with the selected text as search term, is working seamlessly.

Unfortunately an "open context menu and click arrow down on the keyboard" with selenium isn't practical for reaching the context menu entries, therefore, pyautogui is also needed.

When problems occur while running this on another OS than Ubuntu, feel free to report.

adbar commented 1 year ago

Thanks, I'll look at it soon.

Mastercuber commented 1 year ago

Recently I've added another test to the PR for searching with the omnibox API.

Mastercuber commented 1 year ago

Actually, this PR is more a representation of functions instead of a test

Mastercuber commented 1 year ago

Now the tests are also working for Windows 10 (tested in a VM)

adbar commented 1 year ago

Is the PR ready or still work in progress?

Mastercuber commented 1 year ago

This PR is working for firefox 116.0 on Windows and on Linux systems.

It could be, that it's for successful execution of the test.py script - on some systems - necessary, to adjust the caret move value (y value) (in select_text_and_click_context_menu_entry function) to actually hit the context menu entry.

That's the reason, why the PR was marked as WIP. But for a feature representation of the plugin, it should be enough, also if the context menu entry is not hit. The test will go on and search with the omnibox API.

So I would say, with this in mind, it is mergable now.

Mastercuber commented 1 year ago

This commit should clarify what I mean with "adjust the caret move value (y value)"

adbar commented 1 year ago

Thanks, I will get a look at it as soon as I get a chance.

Mastercuber commented 1 year ago

@adbar honestly, the selenium tests are not really needed. I was just curious and though I will share this, since it's a feature representation. If the review of this could take too much time, just ignore this PR!

But if python is installed, executing the tests should be pretty easy. There is a script (setup-tests.sh) which sets up a virtual env. On windows, of course, you need to use WSL or write a BAT script.

All steps are documented in the README.md