Dojo Date text box and history.back() function - dojo

Here is the flow:-
page:-1 select Date from dojo DateTextBox and submit the page. There are couple of text fields along with date text box.
page2:- Review the values submitted in Page1. Have a option to go back using javascript History.back()
Problem:- when I go back other text boxes preserve their values but dojo DateTextField not able to prepopulate with the original value.
How I make the dojo component to remember its value when History.back() gets called?
I know History.back() function render the page from browser cache.
Thanks,
Manoj

The text boxes are remembering their values as a feature of the browser. The Dijit won't do this because the browser doesn't know anything about it. You would have to write custom code and remember the setting via a cookie and set the widget to the value of the cookie on page load (or on widget instantiation).

Related

Selenium: How to get text without clicking on tab?

I'm trying to find text that is located on a specific tab. For some reason the text is available in the html but when I use the command driver.find_element_by_id('hand-graph-title-overview').text without clicking on the 'Overview' tab it returns a empty string. However, when I do click on the 'Overview' tab it will return 'Unpaired OOP' successfully. Does anyone know how to get the text without clicking on the tab?
Images of what I'm trying to scrape.
https://i.stack.imgur.com/9nSc0.png
https://i.stack.imgur.com/MyvDA.png
Maybe try and get the 'value' attribute of the element.
driver.find_element_by_id('hand-graph-title-overview').get_attribute('value')
The answer is no. You can't access the element from the other tab without focusing on it. Retrieval of text is totally based on the presence of the element on the current page. When you click on tab then automatically it gets loaded in the dom and then only you can access the element.

Using puppeteer to automate button clicks for every button at every URL in a web app

I am currently trying to use JS and puppeteer to take a screenshot of every url in my web app, as well as take a screenshot of every button that can be clicked. Is there a way to click each button without specifying the id? Not all of my buttons have an id and even if they did, I wouldn't want to have x number of page.click(id, options) for each button I have (which is quite a lot).
Thanks
I have tried going based off each className (this app is built using react) but this does not work. It will take a screenshot of the same buttons over and over. I believe because if page.click has multiple of the same options, it only chooses the first one and many buttons have the same styling classNames.
You could get an array of each element on a page, go through the elements with a for loop determine if it is a button, then click it. Then for each page you'd have to input each url in an array and then use a for loop to go through it.

Selenium/Rendering Issue, can't read text from input field

I tried to read the text from an input field of a Wicket App, but I failed. The expected text is displayed in the browser, but it is not displayed in the DOM when I open the developer tools in chrome and inspect this field.
The expected text "Profilname_1562052971" is displayed as you can see in the left column of the screenshot, but I can't see this in the DOM (center column). When I have a look at the properties (right column) of this input element, I see value: "Profilname_1562052971", which is what I expected. Why isn’t it displayed in the DOM?
The truth is it probably is in the DOM you just see it as value name="data:name" this comes from the form. The reason you don't see it in the DOM is that the value is inputted by the user and it is added to the attribute value but this is not saved yet into the DOM! When you save this form it will be added.
To validate it with Selenium use element.get_attribute("value").
See jquery API.

retain element values selenium chrome python

I am using selenium-chrome webdriver for logging into a website.
In Page -1 , I am selecting values for multiple fields (includes text fields/drop down etc) and click submit on page 1. This opens page2 and by clicking on 'Generate button' - it downloads an excel file.
Now i need to go back to Page1 and change JUST one value of a drop down field in page 1 and generate another file (same process).
But problem I am facing is, after coming back from Page2, values which were already set in Page1 is refreshed /lost.
How can i make sure, earlier values are not lost, during this process.
Thanks in advance.
Regards,
As you are logging into a website, selecting values for multiple fields and clicking on submit button on page 1 which opens page2; here the page changes. So the DOM tree also gets changed. Selenium is now having the focus on the new HTML DOM. WebElements of the new DOM are attached now. So essentially the WebElements of the previous page are no more attached to the current DOM.
Now as you go back to Page1 and and try to find/search the same values which were already set earlier you will face a StaleElementReferenceException. All you have do is again fill out the fields (text fields/drop down etc).
Here is the official documentation on StaleElementReferenceException

Dijit DateTextArea Behaviour

I am using the dijit dateTextArea and am experiencing some odd behaviour.
I have a simple form with the Dijit dateTextArea. I am setting a default value for the date and it appears fine. If I click into the date area, select a date and hit submit the date is picked up on the other side fine(i.e. it is submitted). If however I don't touch the dateTextArea (i.e. i don't click into it or give it any focus) and submit the form the date is blank, even though the default date has been set. I've tried setting the default date by setting the value on the widget, the initial value and by using data-dojo-props. The date displays in the field but unless I interact with the field the date does not get submitted.
So, what am I doing wrong? Does the field need focus at some point to work properly?
Is there an extra setting I should be using when specifying a default date?
Thanks
It's difficult to tell what's wrong without seeing some code, but you shouldn't have to focus the input or anything for the value to be submitted.
If you look at the "Net" tab in firebug, is the date value part of the request when you submit the form?
I wasn't able to reproduce the problem in jsfiddle.. http://fiddle.jshell.net/DqHxL/ .
How are you referencing the widgit? Is it with dijit.byId or document.getElementById. If you are using dijits you must use dijit.byId not getElement... Dojo creates shadow objects for everything