Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Bot:
- drv: Remote
- conf: dict
- def __init__(self, gui, drv=None):
- options = Options()
- if not gui:
- options.headless = True
- options.add_argument("window-size=1280,720")
- bs = self.conf['browserstack']
- if drv is None:
- self.drv = Remote(command_executor=bs['api_url'], desired_capabilities=bs['desired_cap'])
- else:
- self.drv = drv
- self.conf = getconfig()
- def save_config(self, config: dict):
- data = dumps(config, indent=4, ensure_ascii=False)
- with open(self.config_filename, "w") as f:
- f.write(data)
- config_filename = "config.json"
- class TestSample(Bot, unittest.TestCase):
- def test_sample(self):
- form = self.conf['forms']['sample']
- self.drv.get(form['url'])
- rows = self.drv.find_elements_by_xpath('//*[@id="ext-gen624"]/div')
- for row in rows:
- row.click()
- row_price = row.find_elements_by_xpath('.//tr/td')[1].find_element_by_xpath('./div').text
- panel_price = self.drv.find_element_by_xpath('//*[@id="ext-gen572"]').get_attribute('value')
- self.assertEqual(row_price, panel_price,
- f'Price from row not equals to price on panel: {row_price} != {panel_price}')
- ### Traceback
- Traceback (most recent call last):
- File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
- return _run_code(code, main_globals, None,
- File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
- exec(code, run_globals)
- File "/usr/lib/python3.8/unittest/__main__.py", line 18, in <module>
- main(module=None)
- File "/usr/lib/python3.8/unittest/main.py", line 100, in __init__
- self.parseArgs(argv)
- File "/usr/lib/python3.8/unittest/main.py", line 124, in parseArgs
- self._do_discovery(argv[2:])
- File "/usr/lib/python3.8/unittest/main.py", line 244, in _do_discovery
- self.createTests(from_discovery=True, Loader=Loader)
- File "/usr/lib/python3.8/unittest/main.py", line 154, in createTests
- self.test = loader.discover(self.start, self.pattern, self.top)
- File "/usr/lib/python3.8/unittest/loader.py", line 349, in discover
- tests = list(self._find_tests(start_dir, pattern))
- File "/usr/lib/python3.8/unittest/loader.py", line 405, in _find_tests
- tests, should_recurse = self._find_test_path(
- File "/usr/lib/python3.8/unittest/loader.py", line 460, in _find_test_path
- return self.loadTestsFromModule(module, pattern=pattern), False
- File "/usr/lib/python3.8/unittest/loader.py", line 124, in loadTestsFromModule
- tests.append(self.loadTestsFromTestCase(obj))
- File "/usr/lib/python3.8/unittest/loader.py", line 93, in loadTestsFromTestCase
- loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
- File "/usr/lib/python3.8/unittest/suite.py", line 24, in __init__
- self.addTests(tests)
- File "/usr/lib/python3.8/unittest/suite.py", line 57, in addTests
- for test in tests:
- File "/home/claes/PycharmProjects/spanish_testing/bot.py", line 36, in __init__
- bs = self.conf['browserstack']
- AttributeError: 'TestSample' object has no attribute 'conf'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement