Open th122 opened 6 years ago
Interesting, we haven't got that for our instance (luckily).
Glad the tutorial helped!
Yes, we can make it an optional item in the config file. If you manage to find out which steps are needed to proceed using your static value ('395017700002882'), I can modify it to read the value from the configuration file instead.
If the selection itself didn't work, you could try the Select helper – something like this (not tested!):
from selenium.webdriver.support.ui import Select
element = find_element_by_xpath("//select[@id='pageBeanselectedLocation']")
select = Select(element)
select.select_by_value('395017700002882')
Thanks for the idea - I'm unfortunately still struggling at the find_element_by_xpath which I seem to be calling wrong, no matter how I'm trying to work around that. It all starts with
NameError: name 'find_element_by_xpath' is not defined
and gets consecutively worse as I experiment around that >)
Ah, didn't notice that. It's because find_element_by_xpath
is defined on the driver, more specifically on worker.driver
, so I think this should work:
element = worker.driver.find_element_by_xpath("//select[@id='pageBeanselectedLocation']")
If that works, you can check if this also does:
wait = worker.waiter()
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//select[@id='pageBeanselectedLocation']')))
This effectively does the same, but will wait rather than crash if the element has not yet loaded.
I had tried driver.find... to no avail, worker.driver it was, thanks!
Looking (almost :) good with a few corrections, but the select seems to need a two stage process, first to get the item to display, then it can be selected?
The select bails with a selenium.common.exceptions.ElementNotInteractableException: Message: Element <option> could not be scrolled into view
, unless I previously (manually, will try to automate that on friday) activate the list so it pops open, displaying the item to select:
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from slipsomat.worker import Worker
from slipsomat.slipsomat import TemplateConfigurationTable
from selenium.webdriver.support.ui import Select
worker = Worker('slipsomat.cfg')
worker.connect()
element = worker.driver.find_element_by_xpath("//select[@id='pageBeanselectedLocation_hiddenSelect']")
select = Select(element)
select.select_by_value('3709875230002882')
Yes, you have to ask Selenium to wait selecting until it's clickable. Usually, but not always, something like this works:
wait = worker.waiter()
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//select[@id='pageBeanselectedLocation_hiddenSelect']')))
For our instances, after logging in, staff have to manually select the circulation desk they're using for that session. (independently of their actual workplace):
Until recently, it didn't have any adverse effect on configuration in general if that step was skipped - especially the configuration menu didn't really require selecting the (uneccessary, in that context) circulation desk and worked "anyway".
A user logging in manually is hindered by the pop-up to select the underlying elements of the Alma home screen and has to select a circulation desk. Selenium however happily ignores the intrusive pop-up and proceeds anyway.
As of lately in both Production and Sandbox, this benign behaviour of Alma is no longer the case. If there is no circulation desk selected, the configuration menu is displayed empty:
Slipsomat -which now would rather proceed directly to the configuration menu- gets rather unhappy about this, and bails.
Following the new python/selenium for beginners mini-tutorial (and a big thanks for that help!) I got it to stop at the selection screen after
worker.connect()
.Would it be possible to add either a default circulation desk to slipsomat.cfg, or use the first element of the history as default?
I tried to select one of the circulation desks:
but my hybris was promptly regarded with a number of errors I'm currently trying to learn my way out of.