Skip to content

Commit 23c382f

Browse files
fixing errors: Robot file to add new "headless" argument; updating selenium methods: find_elements_by_xpath to find_elements
1 parent 07ea999 commit 23c382f

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

cumulusci/robotframework/Salesforce.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
StaleElementReferenceException,
1313
WebDriverException,
1414
)
15+
from selenium.webdriver.common.by import By
1516
from selenium.webdriver.common.action_chains import ActionChains
1617
from selenium.webdriver.common.keys import Keys
1718
from SeleniumLibrary.errors import ElementNotFound, NoOpenBrowser
@@ -892,7 +893,8 @@ def _locate_element_by_label(self, browser, locator, tag, constraints):
892893
fieldset_prefix
893894
+ f'//label[descendant-or-self::*[text()[normalize-space() = "{label}"]]]'
894895
)
895-
labels = browser.find_elements_by_xpath(label_xpath)
896+
labels = browser.find_elements(By.XPATH, label_xpath)
897+
896898
if not labels:
897899
return []
898900

cumulusci/robotframework/Salesforce.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Chrome Set Headless
186186
... This keyword is not intended to be used by test scripts
187187
188188
[Arguments] ${options}
189-
Call Method ${options} set_headless ${true}
189+
Call Method ${options} add_argument --headless
190190
Call Method ${options} add_argument --disable-dev-shm-usage
191191
Call Method ${options} add_argument --disable-background-timer-throttling
192192
[return] ${options}

cumulusci/robotframework/form_handlers.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from robot.libraries.BuiltIn import BuiltIn
44
from selenium.common.exceptions import TimeoutException
5+
from selenium.webdriver.common.by import By
56

67
from cumulusci.utils.classutils import get_all_subclasses
78

@@ -61,9 +62,7 @@ def selenium(self):
6162
@property
6263
def input_element(self):
6364
"""Returns the first <input> or <textarea> element inside the element"""
64-
elements = self.element.find_elements_by_xpath(
65-
".//*[self::input or self::textarea]"
66-
)
65+
elements = self.element.find_elements(By.XPATH, ".//*[self::input or self::textarea]")
6766
return elements[0] if elements else None
6867

6968
@abc.abstractmethod
@@ -130,9 +129,8 @@ class LightningComboboxHandler(BaseFormHandler):
130129
@property
131130
def input_element(self):
132131
"""Returns the base form element (input or button) that the combobox is based on"""
133-
elements = self.element.find_elements_by_xpath(
134-
".//*[contains(@class, 'slds-combobox__input')]"
135-
)
132+
elements = self.element.find_elements(By.XPATH, ".//*[contains(@class, 'slds-combobox__input')]")
133+
136134
return elements[0] if elements else None
137135

138136
def set(self, value):

cumulusci/robotframework/pageobjects/BasePageObjects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
from selenium.common.exceptions import NoSuchElementException, TimeoutException
1515
from SeleniumLibrary.errors import ElementNotFound
16+
from selenium.webdriver.common.by import By
17+
1618

1719
from cumulusci.robotframework.form_handlers import get_form_handler
1820
from cumulusci.robotframework.pageobjects import BasePage, pageobject
@@ -261,7 +263,8 @@ def _get_form_element_for_label(self, label):
261263

262264
# also, we use find_elements (plural) here because it will
263265
# return an empty list rather than throwing an error
264-
modals = root.find_elements_by_xpath("//div[contains(@class, 'uiModal')]")
266+
# modals = root.find_elements_by_xpath("//div[contains(@class, 'uiModal')]")
267+
modals = root.find_element(By.XPATH, "//div[contains(@class, 'uiModal')]")
265268
# There should only ever be zero or one, but the Salesforce
266269
# UI never ceases to surprise me.
267270
modals = [m for m in modals if m.is_displayed()]

0 commit comments

Comments
 (0)