فهرست منبع

修改定位语句text() or span[text()]问题:如定位销售订单—业务类型和样品通知单—是否收费

zhaiqq 3 هفته پیش
والد
کامیت
20af08eab2
3فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 2 2
      pages/head_page.py
  2. 1 1
      pages/locator/head_page_locator.py
  3. 1 1
      pages/login_page.py

+ 2 - 2
pages/head_page.py

@@ -70,8 +70,8 @@ class HeadPage(BasePage):
         """
         # Locator.click()普通点击无法弹出下拉选项值,使用force强制点击
         # 注意:force=True强制点击不执行非必要的元素可操作性检查
-        self.page.locator(HeadPageLocator.SELECT_FIELD_ARGS_LOC % field_name).click(force=True)
-        self.page.locator(HeadPageLocator.SELECT_ITEM_ARGS_LOC % item_value).click()
+        self.page.locator(HeadPageLocator.SELECT_FIELD_ARGS_LOC % field_name).click()
+        self.page.locator(HeadPageLocator.SELECT_ITEM_ARGS_LOC % (item_value,item_value)).click()
 
     def _set_textarea(self, field_name:str, value:str):
         """

+ 1 - 1
pages/locator/head_page_locator.py

@@ -20,7 +20,7 @@ class HeadPageLocator:
     BASE_FIELD_SPAN_ARGS_LOC = "//div[contains(@id, '-FMAINTAB_c-') and @class='k-content k-state-active']//div[contains(@id, 'SPLITECONTAINER') and @splitter='first']//div[contains(@id, 'TAB') and @class = 'k-content k-state-active']//span[translate(text(), ' ', '') = translate('%s', ' ', '')]/parent::div/following-sibling::div[1]/descendant::input/following-sibling::span"
     BASE_ITEM_ARGS_LOC = "//div[@class = 'k-animation-container' and contains(@style, 'display: block')]//table[@class = 'k-selectable']/descendant::td[text() = '%s']"
     SELECT_FIELD_ARGS_LOC = "//div[contains(@id, '-FMAINTAB_c-') and @class='k-content k-state-active']//div[contains(@id, 'SPLITECONTAINER') and @splitter='first']//div[contains(@id, 'TAB') and @class = 'k-content k-state-active']//span[translate(text(), ' ', '') = translate('%s', ' ', '')]/parent::div/following-sibling::div[1]//span[@class = 'k-select']"
-    SELECT_ITEM_ARGS_LOC = "//div[@class = 'k-animation-container' and contains(@style, 'display: block')]/div/div[2]/ul/li[text() = '%s']"
+    SELECT_ITEM_ARGS_LOC = "//div[@class = 'k-animation-container' and contains(@style, 'display: block')]/div/div[2]/ul/li[text() = '%s' or .//span[text() = '%s']]"
     #获取字段值相关定位
     TEXT_VALUE_INPUT_ARGS_LOC = "//div[contains(@id, '-FMAINTAB_c-') and @class='k-content k-state-active']//div[contains(@id, 'SPLITECONTAINER') and @splitter='first']//div[contains(@id, 'TAB') and @class = 'k-content k-state-active']//span[@role='kdspanlabel' and @title = '%s']/parent::div/following-sibling::div[contains(@class, 'kdItemContainer_editorct')]//input"
     TEXT_VALUE_SPAN_ARGS_LOC = "//div[contains(@id, '-FMAINTAB_c-') and @class='k-content k-state-active']//div[contains(@id, 'SPLITECONTAINER') and @splitter='first']//div[contains(@id, 'TAB') and @class = 'k-content k-state-active']//span[@role='kdspanlabel' and @title = '%s']/parent::div/following-sibling::div[1]/descendant::span[@class = 'ui-poplistedit-displayname']"

+ 1 - 1
pages/login_page.py

@@ -23,7 +23,7 @@ class LoginPage(BasePage):
         try:
             self.page.locator(LoginPageLocator.DATA_CENTER_ARROW_DOWN_LOC).click()
             # 偶发页面加载后直接点击账套下拉列表,下拉选项闪现点击无反应。判断点击后1s内下拉选项是否显示,如不显示重新点击
-            expect(self.page.locator(LoginPageLocator.DB_SELECT_ITEM_ARGS_LOC % db)).to_be_visible(timeout=1000)
+            expect(self.page.locator(LoginPageLocator.DB_SELECT_ITEM_ARGS_LOC % db)).to_be_visible(timeout=2000)
         except AssertionError:
             self._choice_db(db)
             return