Skip to content

Commit 1643678

Browse files
Updating other Xpath error messages within Salesforce.py and PasePageObjects.py
1 parent 23c382f commit 1643678

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

cumulusci/robotframework/Salesforce.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from selenium.webdriver.common.action_chains import ActionChains
1717
from selenium.webdriver.common.keys import Keys
1818
from SeleniumLibrary.errors import ElementNotFound, NoOpenBrowser
19+
from selenium.webdriver.common.by import By
1920
from urllib3.exceptions import ProtocolError
2021

2122
from cumulusci.robotframework import locator_manager
@@ -608,7 +609,7 @@ def select_app_launcher_app(self, app_name, timeout=30):
608609
self.selenium.wait_until_page_contains_element(locator, timeout)
609610
self.selenium.set_focus_to_element(locator)
610611
elem = self.selenium.get_webelement(locator)
611-
link = elem.find_element_by_xpath("../../..")
612+
link = elem.find_element(By.XPATH, "../../..")
612613
self.selenium.set_focus_to_element(link)
613614
link.click()
614615
self.wait_until_modal_is_closed()
@@ -908,9 +909,7 @@ def _locate_element_by_label(self, browser, locator, tag, constraints):
908909
# probably never be. Famous last words, right?
909910
orig_wait = self.selenium.set_selenium_implicit_wait(0)
910911
component = None
911-
component = label_element.find_element_by_xpath(
912-
"./ancestor::*[starts-with(local-name(), 'lightning-')][1]"
913-
)
912+
component = label_element.find_element(By.XPATH, "./ancestor::*[starts-with(local-name(), 'lightning-')][1]")
914913
except NoSuchElementException:
915914
component_id = label_element.get_attribute("for")
916915
if component_id:

cumulusci/robotframework/pageobjects/BasePageObjects.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ def _get_form_element_for_label(self, label):
263263

264264
# also, we use find_elements (plural) here because it will
265265
# return an empty list rather than throwing an error
266-
# modals = root.find_elements_by_xpath("//div[contains(@class, 'uiModal')]")
267266
modals = root.find_element(By.XPATH, "//div[contains(@class, 'uiModal')]")
268267
# There should only ever be zero or one, but the Salesforce
269268
# UI never ceases to surprise me.
@@ -275,7 +274,7 @@ def _get_form_element_for_label(self, label):
275274
# where "for" points to the associated input field. w00t! If we can,
276275
# use that. If not, fall back to an older strategy
277276
try:
278-
label_element = root.find_element_by_xpath(f'//label[text()="{label}"]')
277+
label_element = root.find_element(By.XPATH, f'//label[text()="{label}"]')
279278
input_id = label_element.get_attribute("for")
280279
element = root.find_element_by_id(input_id)
281280
return element
@@ -288,7 +287,7 @@ def _get_form_element_for_label(self, label):
288287
# has a child element with the class 'form-element__label' and
289288
# text that matches the given label.
290289
locator = f".//*[contains(@class, 'slds-form-element') and .//*[contains(@class, 'form-element__label')]/descendant-or-self::text()='{label}']"
291-
element = root.find_element_by_xpath(locator)
290+
element = root.find_element(By.XPATH, locator)
292291
return element
293292

294293
except NoSuchElementException:

cumulusci/robotframework/tests/salesforce/forms.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Lightning based form - radiobutton
119119
# Using the label: locator returns a lightning-input element. We need to find
120120
# the actual html input element to verify that it is checked. Ugly, but efficient.
121121
${element}= Get webelement label:All users can see this list view
122-
Should be true ${element.find_element_by_xpath(".//input").is_selected()}
122+
Should be true ${element.find_element(By.XPATH, ".//input").is_selected()}
123123

124124
Non-lightning based form - radiobutton
125125
[Documentation] Verify we can set a plain non-lightning radiobutton

0 commit comments

Comments
 (0)