for that reason I do not want to use driver as it is global and therefor is not precise enough
michl68 joined the channel
michl68 has quit
jimevans
zathras: oh. of course. the 'day' element isn't a child of the <input> element that you've found in your find_element call...
titusfortner has quit
they're in entirely different trees in the DOM.
zathras
hmm. Must I select a pop up first or something jimevans ?
errant_rider
anyone here play with UFT at all?
jimevans
zathras: it depends on what you're *actually* trying to do.
it looks like the same element gets repurposed for both date fields.
so if you're trying to select a date using the calendar widget, that's one use case.
if you're simply trying to figure out what date is currently selected, that's another use case.
zathras
jimevans, what I try to do is 2 fold: a) read current settings (date) and b) set both pickers to a specific date
jimevans
zathras: reading the current date shouldn't require the use of the date picker at all.
you should be able to read it directly from the <input> element.
zathras
well, it is required to see if the current calender date is the desired date
jimevans
but to use it to select a date, as near as i can tell, you'll need to click the <input> element, and find the <div> representing the date picker from the root of the DOM. in other words, using driver.find_element… is the right thing to do.
zathras
yes, that was my original code (option 1 as I called it in my paste), but that does not specify which picker to use
titusfortner joined the channel
jimevans
zathras: as i said first thing, the date picker is not tied to the <input> element where the date is displayed at all.
when one of the two date fields is clicked on, the date picker is initialized with the date found in that date field.
tyang has quit
the same date picker is used for both date fields.
(or it's being deleted and recreated in the DOM, which amounts to the same thing)
zathras
ok. thanks!
jimevans
zathras: all i'm doing to figure this out is looking at the DOM structure using the browser's developer console (right-click on an element in the page and choose "inspect element")
zathras
atm I am using the development tools plugin of chrome to do more or less that
but the DOM is much bigger, so an overview is not always trivial
jimevans
then you've already noticed that the date picker's root element is a direct child of <body>, and thus isn't tied in any way to a specific date field.
and, since you're already comfortable using the development tools in chrome, know that you can always double-check your css selectors right there in the dev tools, without even bringing selenium into it.
which has the added benefit of helping you figure out if you're selecting the right element in the first place.
zathras
I also installed a selenium/css plugin but it just seems to list elements
jimevans
"a selenium/css plugin"?
zathras
how does that css checking works jimevans ?
jimevans
zathras: very easily. in the dev tools, go to the javascript console and type `document.querySelector('<your selector here>')`
zathras
"CSS Selector Helper for Chrome™"
ah. nice. ty
jimevans
if it returns the element you're expecting in the javascript console, you're golden.
and if you need to check child elements, you can do this: `var foo = document.querySelector('<parent selector>'); foo.querySelector('<child selector>')`
i usually do that last on separate lines if i need to .
but it's simple and it uses only the browser's technology, which is what webdriver will use anyway in the case of css selectors