最近私は新しいプロジェクトに切り替えました。私たちのすべてのセレニウムテストはPythonで書かれています。 click.view_button
デコレータを使用したリファクタリングによるコード量の削減
self.find(self.view_button).click()
を最小限にする方法がある私は考えている
class BasePage(object):
view_button = ".//a[text()='View']"
create_button = ".//a[text()='Create']"
#some code here
class BaseTestCase(unittest.TestCase):
setUpclass(cls):
#code here
def find(cls,xpath):
return cls.driver.find_element_by_xpath(xpath)
class SomeTest(BaseTestCase):
def test_00_something(self):
self.find(self.view_button).click()
:私はデコレータ
を使用して、コード量を減らすことができれば、私たちは今持っているかと思いました
私はそれがデコレータを使って行うことができると聞きましたが、私はそれでほとんど成功しなかったJavaの人です。