Missing Angularjs HTML elements in Phantomjs - phantomjs

I am crawling a website. I must change the date of the given job when suddenly I realized that the element is missing. When I screen capture it, the element is really missing. Is there any way to render that element? The website runs with Angularjs because I noticed the ng in the HTML code. Here are the pictures, the first one is the desktop capture and the second one is from the phantomjs.
Normal date in web browser
No date, straight to the next label

I found how to solve this, just wait for the angularjs to load on phantomjs. It takes an estimate of 5 seconds before it loads. The best to do here is setTimeout function.

Related

Robotframework - Selenium - How to verify page loaded completely (successfully) without relying on a specific element in the page?

I was wondering if there is anything in Selenium that can verify if a page loaded completely without relying on a specific element in the page to appear (while using the "wait until page contains" or similar keywords).
The idea is reusability. If there is a need to add new websites to the robot automation later, I do not want to rely on a specific element that might exist in one page but not in another to verify if the page loaded fully.
Is there any keyword that addresses that in Robot Framework - Selenium Library?
Thanks!
Edit - I am aware that some AJAX requests are impossible or extremely difficult to conclude if they finished or not (or if they just keep going forever) so let's assume the website does not have any of that.
Once the page is finished loading, all requests are done.
driver.execute_script("return document.readyState === 'complete'")
use execute script document.readyState , if it returns complete it means the loading have finiished.
But if there is no ajax you don't have to do it selenium does it automatically so your question won't be valid:
https://www.selenium.dev/documentation/en/webdriver/page_loading_strategy/#:~:text=Defines%20the%20current%20session's%20page,loading%20takes%20lot%20of%20time.
normal This will make Selenium WebDriver to wait for the entire page
is loaded. When set to normal, Selenium WebDriver waits until the load
event fire is returned.
By default normal is set to browser if none is provided.
I couldn't find some built-in option but there is another way to achieve this. Check if your web app uses any third-party library which shows progress bar, if yes then probably there is function which returns the status of page loading including Ajax call. If not, then you can ask devs to add some progress bar, for instance Pace.JS
document.readyState does not wait for Ajax calls, personally I found it less helpful.

javascriptexecutor.executescript is not working on some applications

I am working on web application which is implemented with angular and react js. In this, I have a scenario to scroll and check whether element is displaying or not.
I have tried all ways like using x,y values, scrollIntoView and all possible ways what I have noticed on different blogs and technical related web pages. But, i an not succeeded in it.
Here, I need some suggestions like what are other approaches we have to scroll webpage other than javascriptexecutor as this is already applied and failed in my case.
As a side note, elements will be loaded dynamically when we scroll the webpage and will not be available in the DOM itself. To get these elements, we have to scroll manually and check it.
Thanks in Advance..
I found a root cause why javascriptexecutor is not working on my application. This script will work only on browser (I.e. if browser have scroll bar), but in my application browser does not have a scroll bar instead it has virtual table scroll bar (scroll bar inside application).
Even I found a solution for the same after 2 days of investigation using Keys.PAGE_DOWN/UP inside do while loop.
Thanks for your support.

Selenium catch HTML every time change has been made in browser

Is it possible to use Selenium so that my code and browser will be integrated - I want to get updated HTML page every time I made any change on the web page in the browser?
In other words I would like to run my app which would automatically start a browser and every time I do any change on the web page selenium automatically get changed HTML in java/python code. For example select a dropdown item might be a good example.
Thanks!

capturing a browser refreshed event using Selenium Web Driver

I am writing a program to automate link validations in a site. Our site is having more than 400 links per page and we need to open each link and see it is returning a valid page i.e 200, there are other requirements as well to check if the page is a 404 redirection page etc. It means to validate 400 inks it will take about 30 minutes or so.
My design is to integrate this with the Front-End (Selenium) automation in a way that each time the browser loads a new page or browser refreshes it will trigger a new thread by passing the page source for validating all the href available.
We are not following a page object model otherwise I could trigger this in my each page.
Question here is that is there any way we can listen to a browser refresh or page load event using Selenium Web Driver?
Correct me if I don't understand your question, but page_refresh and page_load_event can be two very different goals for you, if you are dealing with AJAX. You can try this article about the AJAX part
and this one for selenium custom events synchronization.
This solution here is the most actual I could find.
Actually Selenium is JS driver so this answers can be helpful if you want to try it too:
check-if-page-reloaded-or-refresh-in-js
is-page-reloaded-or-refreshed-using-jquery-or-javascript
post_detect_refresh_with_javascript

Does changing the order of HTML with Javascript help SEO

On my website, I have a booking widget at the top of each page to allow visitors to enter our booking engine. The code behind it uses quite a bit of HTML, pushing down the content on each page in the source. In an attempt to better my SEO, I decided to have the code placed in a DIV tag at the bottom of the page, and, when the DOM is ready, I use JQuery to physically move the DIV from the bottom of the DOM to the top where it needs to be to render correctly.
My question is if this is really helping SEO? Does Google look at the DOM/Source after all Javascript has run, or before? Does moving these few hundred lines of HTML to the bottom of the HTML source gain me any advantage?
Spiders do not process javascript. So any content that appears/moves or is created by javascript will appear as if it hasn't been moved or created at all.
I'd be really surprised if web crawlers execute the scripts on the page. They probably scan the raw response.
That doesnot have any effect on the SEO.
But placing the javascript at the bottom will defnitely help you to load the webpages faster.
There is no harm for SEO as well, you can defnitely proceed with your approach
There is a distinction between javascript executed on load versus during the user session. The on-load javascript is more times than not indexed by google. The dynamic content or alterations on the client side are not well indexed.
So, it can't be ignored.