Element not found in the cache - perhaps the page has changed since it was looked up - selenium

I'm using Watir webdriver to click on all the links with the same title on a webpage.
browser.links(:title => 'Hide week').each(&:click)
However, it sometimes happens and I get this error message:
Element not found in the cache - perhaps the page has changed since it was looked up
I need the program to click on a 'turn editing on' button first, then the page will reload and configuration buttons/icons will show. Then each(&:click) should click on the buttons/icons. Is there another way of clicking on a group of links that can avoid 'Element not found in the cache'?
Thank you.

There is no other way apart from initializing the elements again, before clicking them.

Related

Right click on element leads to new page unable to inspect the element

I am facing a strange issue while identifying the element on one of the webpages in my application. There are links on the page and I need to click those links and perform the necessary steps.
When I right click on those links then it immediately takes me to that page, I am not able to inspect that link element. When I use inspect tool tip and mouse over any of the link then it highlights a big window where all the links are located and in the elements section nothing shows up, at least I thought I will find those links in view source. Any help is greatly appreciated.
enter image description here
just press ctrl+shift+i
to open the inspect tool , sometime website will have event listeners for right mouse click to some other tasks . IN such case you can open dev tool using this short cut

Inspect Element shows elements for just a few seconds before all of the rows collapse

It was suggested that this had already been answered and then my question was closed.
I've looked at all of the links and I don't see an answer there. Please don't close my question unless you're absolutely sure it's been answered.
Why XPath does not highlighted the yellow mark in Chrome84? (2
answers)
Chrome 84 Inspect element, find results not highlighted in
yellow like before (6 answers) Chrome DevTools not find elements not
search)
I'm writing some Selenium code and need to get the CSS Selector for an item on a page. So I bring up the page and go into Tools mode. It doesn't matter which browser I use - Chrome, FireFox, Edge - when click on the "Pick an element from the page" button (to the left of the Inspector in FireFox) and then click on the item I need the CSS Selector for I see the element in the tools section, but as I'm right-clicking it and choosing Copy->CSS Selector, the table it's in collapses (in a second or two) and I no longer have access to the item I clicked on. I've tried manually expanding the TR in the tools view and drilling down to the TD I need, but the same thing happens.
Anyone know of a way to stop this from happening? I was quick enough to copy a few yesterday but for some reason it seems to be happening faster today and I'm not able to catch it.
Right-clicking the item and choosing Inspect Element was also suggested but that does the same thing. The item shows up in the tools section for about 2 seconds and then the table collapses.
When the element tree collapses, it is a sign that it got updated. This happens, for example, when an iframe's URL or document is changed or the child tree structure gets replaced via JavaScript.
In order to stop this from happening, you can stop the JavaScript execution on the next execution once you see the element you want to inspect. Then you are able to inspect the element using the inspect button.
Firefox
Switch to the Debugger panel.
Once you see the element you want to inspect, click the Pause button or press F8.
Cause the JavaScript execution to stop (e.g. by interacting with the page). You can see that the JavaScript execution is stopped when there is a white overlay on the page and a hint saying Paused at Execution.
Once the execution is stopped, click the Pick an element from the page button in the toolbar or press Ctrl+Shift+C.
Click the element you want to inspect.
Chrome/Edge
Switch to the Sources panel.
Once you see the element you want to inspect, click the Pause script execution button or press F8.
Cause the JavaScript execution to stop (e.g. by interacting with the page). You can see that the JavaScript execution is stopped when there is a hint on the page saying Paused in debugger.
Once the execution is stopped, click the Select an element in the page to inspect it button in the toolbar or press Ctrl+Shift+C.
Click the element you want to inspect.
I found a semi-workable solution. When the item appears in the tools window note it's name before it disappears. Then go to the Search HTML box and type it's name. It still appears and then disappears, but it seems to stay visible longer.

How to handle dynamic error messages coming in an application

I am facing an issue while automating a web application at my work-place, and need helping advise to resolve the issue.
The application which I am testing is having a dynamic error popup screen which loads from the top whenever any error comes in the application. To be more clearer, let's say I am entering Username and password to login into application, and I took wrong username and password combination. Now, due to this a dynamic error drop down comes from the top. I am saying it dynamic because, as soon as I am trying to inspect the element, the error screen fades away. Now, due to this, I am not able to locate the element.
Sometimes, I got lucky and was able to inspect the element by right-clicking on that element. But then as soon as I reach to element tab, Error screen fades away, and not able to inspect the element.
So, I need help here to know how can I handle this dynamic error screen.
Any help will be appreciated. :-)
You can use devtools to pause:
1. Open app in chrome
2. Open devtools
3. Go to Sources tab
4. Trigger error and press F8 to pause
5. Go to Elements tab and locate error html
Two quick ways :
When you get lucky to reach until the elements tab after inspecting
the error, just copy the total div/span/error element's html code.
Paste it in a Notepad to locate the element with any strategy [like
xpath/css].
If the above could not help, then ask the dev to make the dynamic
error message to appear some more time and then you could locate
them correctly.

Magnific-popup - Source (not showing up again) after closing Popup

I'm trying to implement the Magnific-popup on a website. Source is a jquery ( html articles with a header paragraphs...) object loaded as inline type. The shown source is on the same page as the popup. To this point it is working fine, popup is working, content is loaded.
Now I'm unsure whether this is standard behaviour or not: In the background the shown article is hidden, while the rest of the articles are still there. When closing the popup, the shown article stays hidden.
tl;dr: Magnific-popup hides the source of the opened information, not making it visible again after closing the popup.
Am I doing anything wrong or is it just the expected behaviour of Magnific-popup?
Any hints/solutions appreciated.
its general behavior.
when you close the popup once, it adds class "popup-hide" to hide the popup content, though which may not be applied by you in its html
i hope you are referring to something like this : http://www.hoopsvilla.com/2014/04/2014-nba-playoffs-bracket-tree-updated-scores-stats-schedule.html (when you click the trigger (the team logo), the inline-content gets hidden once the popup is closed.)
i'll try to get more (solution) on this later.. :)

Selenium cannot click tab in magento module detail page

I'm trying to validate data using selenium version 1.0.9 in magento grid and its detail page.
First, I walked through Selenium IDE from login page to module detail page and click the tabs available there. Eventually, IDE generates PHP codes so I put the code into proper location.
Note: Here, I have clicked the two tabs so that the events get recorded into selenium IDE.
Then, I run the code from command prompt using following command:
phpunit --configuration /var/www/tests/phpunit_test.xml
I got the error (something like):
ERROR: Element //a[#id='test_tabs_form_section']/span not found.
I modified the code and tried to open the detail page before executing click to above link i.e. "test_tabs_form_section", I am getting same error.
Another strange this is if I verify any text of detail page and remove the code that calls click to module detail tabs, it is works, not sure why?
But I really want to open detail page and click to tab, get forms element values using xpath and validate the data.
Can somebody help me, please?
Any help or suggestion is highly appreciable!
Looking forward to hear from stackoverflow geeks!
Thanks
In case this helps anybody:
I found out more things work if firebug is active. This actually makes sense cause firebug will show the final DOM tree in all it's debugging screens, so it's possible selenium is now able to reconstruct the element path because firebug altered the internal DOM.
If something doesn't work with the default element selection created by Selenium IDE, try switching it over to xpath:id-relative. You're already using that in your question, so maybe you there's an even better selector or you will need to resort to using clickAt instead of click.