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 #15

Merged
merged 1 commit into from
Nov 24, 2018
Merged

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

merged 1 commit into from
Nov 24, 2018

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

Changes and Additions:

  • Adds type conversion to float for the radius value in _blur_regions function. See issue description below.
  • Updates gitignore: ignores IDE config files.

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).

**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 jessezach merged commit 216d237 into jessezach:master Nov 24, 2018
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