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

Adds type conversion for the radius value in _blur_regions function #18

Closed
wants to merge 2 commits into from
Closed

Adds type conversion for the radius value in _blur_regions function #18

wants to merge 2 commits into from

Conversation

DiegoSanchezE
Copy link
Contributor

Environment:
OS: Windows 10
Browser: Chrome
Version: 70.0.3538.102 (Official Build) (64-bit)
Robot Framework: 3.0.4
Python: 3.7.0

Issue:
This is how I'm declaring the radius scalar variable in my Robot Framework test case:

*** Variables ***
@{blur}         ${LOGIN_PASSWORD_INPUT}    ${LOGIN_BUTTON}
${tolerance}    0.05
${radius}       0.9

However, I was seeing the following error when using the radius argument in the capture full screen keyword:
TypeError: must be real number, not str

I narrowed down the issue to the init.py file, line 298, in the _blur_regions function:
blurred_image = cropped_image.filter(ImageFilter.GaussianBlur(radius=radius))
The code is expecting a float, but is interpreting (for some reason) that the argument is a string. (perhaps a Robot Framework limitation?)

Fix:
I implemented type convertion from string to float to that argument:
blurred_image = cropped_image.filter(ImageFilter.GaussianBlur(radius=float(radius)))

Testing:

  • Run the Example test case (see ReadMe file) in test mode and play around with the radius value.

Expected result:

  • The radius value should be reflected in the screenshots.
  • Nothing should break regardless of entering a string or int numerical value (alphabetical values will obviously fail).

Additional changes:

  • Adds Pycharm config directory to gitignore file (trivial).

DiegoSanchezE added 2 commits November 23, 2018 14:37
**Environment:**
OS: Windows 10
Browser: Chrome
Version: 70.0.3538.102 (Official Build) (64-bit)
Robot Framework: 3.0.4
Python: 3.7.0

**Issue:**
This is how I'm declaring the `radius` scalar variable in my Robot Framework test case:
```
*** Variables ***
@{blur}         ${LOGIN_PASSWORD_INPUT}    ${LOGIN_BUTTON}
${tolerance}    0.05
${radius}       0.9
```

However, I was seeing the following error when using the `radius` argument in the `capture full screen` keyword:
`TypeError: must be real number, not str`

I narrowed down the issue to the __init__.py file, line 298, in the _blur_regions function:
`blurred_image = cropped_image.filter(ImageFilter.GaussianBlur(radius=radius))`
The code is expecting a float, but is interpreting (for some reason) that the argument is a string. (perhaps a Robot Framework limitation?)

**Fix:**
I implemented type convertion from string to float to that argument:
`blurred_image = cropped_image.filter(ImageFilter.GaussianBlur(radius=float(radius)))`

**Testing:**
- Run the Example test case (see ReadMe file) in `test` mode and play around with the `radius` value.

**Expected result:**
- The radius value should be reflected in the screenshots.
- Nothing should break regardless of entering a string or int **numerical** value (alphabetical values will obviously fail).
@jessezach
Copy link
Owner

This Pull request was merged into master. Opened unintentionally?

@DiegoSanchezE
Copy link
Contributor Author

Aw snap! Sorry, I hadn't noticed.
Closing this PR.
Thanks!

@DiegoSanchezE DiegoSanchezE deleted the bugfix-radius-string2float branch April 8, 2022 22:06
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.

None yet

2 participants