You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError: 'WebElement' object has no attribute 'get_screenshot' #73
Hi,
I started looking into needle (instead of ApliTools) and trying to create a test but facing an issue with this command: element.get_screenshot().save(baseline_file)
In compareScreenshot() method cases.py file
File "C:\Python27\lib\site-packages\needle\cases.py", line 238, in compareScreenshot
element.get_screenshot().save(output_file)
AttributeError: 'WebElement' object has no attribute 'get_screenshot'
My guess that the driver that am referring to is the selenium web driver, but the one used in cases.py is the needle driver!
My code:
from needle.cases import NeedleTestCase
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
I switched to Needle Driver: self.driver = self.get_web_driver()
But now I'm getting:
File "C:\Python27\lib\site-packages\needle\cases.py", line 241, in compareScreenshot
self.engine.assertSameFiles(output_file, baseline_file, threshold)
AttributeError: 'NebulaTest' object has no attribute 'engine'
This command line: self.engine.assertSameFiles(output_file, baseline_file, threshold)
But these aren't regular installations, the FreeImage for example is a dll... I have a feeling that am going in a wrong direction.
Can you please give more insights on it
calling from my Test class: self.setUpClass()
did the trick.
I still have one question regarding saving the base-line image....
by running: nosetests Needle.py --with-save-baseline I'm getting
c:\workspace_medalia\robotautomation\Galil-RF\RobotFramework\Libraries\VisualTesting>nosetests Needle.py --with-save-baseline
E
======================================================================
ERROR: Failure: IOError (The baseline screenshot C:\VisualTesting\screenshots\baseline\feedback.png does not exist. You might want to re-run this test in baseline-saving mode.)
I order to come over it, I had overridden the save_base_line in my test class: self.save_baseline = True
Isn't there an option to pass it as parameter? the --with-save-baseline was suppose to deal with it, no?!
I had a similar problem at first but I believe I figured out what I was doing wrong. You need to use the driver object that has the NeedleWebDriverMixin. You're using regular chrome when you do
self.driver = webdriver.Chrome()
To do use the one with the Needle mixin, I overrode get_web_driver.
from needle.cases import NeedleTestCase
from needle.driver import NeedleChrome
class ExampleTest(NeedleTestCase):
@classmethod
def get_web_driver(cls):
return NeedleChrome()
def test_example(self):
self.driver.get('http://example.com')
self.assertScreenshot('body', 'example-body')
Activity
mzbedat commentedon Jul 3, 2017
I switched to Needle Driver:
self.driver = self.get_web_driver()But now I'm getting:
This command line:
self.engine.assertSameFiles(output_file, baseline_file, threshold)From this link I can see that I need to download and install PerceptualDiff:
http://the-creative-tester.github.io/Python-Visual-Regression-Testing/
that's require:
But these aren't regular installations, the FreeImage for example is a dll... I have a feeling that am going in a wrong direction.
Can you please give more insights on it
mzbedat commentedon Jul 3, 2017
calling from my Test class:
self.setUpClass()did the trick.
I still have one question regarding saving the base-line image....
by running: nosetests Needle.py --with-save-baseline I'm getting
I order to come over it, I had overridden the save_base_line in my test class:
self.save_baseline = TrueIsn't there an option to pass it as parameter? the --with-save-baseline was suppose to deal with it, no?!
jeremyqa commentedon Aug 24, 2017
I had a similar problem at first but I believe I figured out what I was doing wrong. You need to use the driver object that has the NeedleWebDriverMixin. You're using regular chrome when you do
To do use the one with the Needle mixin, I overrode get_web_driver.
That came mostly from https://needle.readthedocs.io/en/latest/#selecting-a-webdriver