DOM Element Load Time Benchmarking - selenium

I'd like to benchmark my web application. Specifically I'd like to measure the load time of a particular DOM element.
I can use webdriver's wait for visible to measure how long a an element took to load and save the result somewhere. However I'd also like to measure concurrency and other factors.
Is there a standard way to do this?

While I love WebdriverIO, I would recommend using a tool other than it for benchmarking. WebdriverIO uses HTTP requests to send commands to Selenium, and because of that isn't the most performant thing. Your stats could be way off simply because the request from WebdriverIO to Selenium takes longer than usual.
I'd suggest using a tool a little "closer to the metal", possibly CasperJS

Related

is there some way to get all the invalid locators in selenium automation?

I have many locators and if any one among them fails the program fails, We can not get a list of locators failed.
is there some way/method to get all the invalid locators in selenium automation???
The easy way (in case of you're using a framework and the code is well structured) :
Add the action performed on any locator into a try-catch block and store locator's name into a file, log it into console etc (it's up to you). In this way, you can follow up and update them after.
The manual way:
Go manually trough all your locators and look after them in HTML code in browser's console
The less painful manual way:
Execute all tests, and from your report (if you're using any reporting tool) or from console, collect and check each locator .
Now, if you're just doing a clean-up, I recommend the first approach. If you're facing issues with the locators, flaky situations, I recommend creating dynamic locators (xpath or css).

How to continue test when the page still not completely loaded in selenium

Actually, I am creating automation testing for an e-commerce website. Actually, the website have function lazy load or something. I am testing it on UAT server. So, it will load the page slowly because the specification of the server. It takes more than 60 sec or more to load all the resources from the webpage. So, when I am trying to create selenium automation, it always waiting more than 60 sec to continue the next step (because waiting the page fully loaded). Please, someone give me tips how to continue run the test step after 10 seconds wait the page to load. It won't throw an exception, just continue the test step.
Not possible.
If you find some element and try execute some action while loading you will get stale element error + due loading issue you will have a lot of failed tests and it will take a lot more time to debug.
Automation means to execute fast and have reliable results.
It seems that this environment is not built for automation, you should request more resources.
As an alternative maybe you can use a headless driver or see if you can put the same build on a VM.
Why this is an issue: Selenium needs to wait for each request to be complete.For example when you request a page, if the page is not received entirely and the server still sending info then the request is not done, it is logical that you need a complete request in order to continue.
You should address this to your Project Manager/QA Lead and ask for advice/option on how to handle this.
Please note that these costs should be included/added in the automation price.You need to address this in a simple way:
good server -> automation runs smoothly and fast and the testing is
done faster
bad server -> unable to run automation since is not reliable and each
test has a high rate of failure => alternative X day(s) of
manual testing for each build
If this would be a coding issue like some delayed ajax request then you would have some solutions, devs could help, but if is an infrastructure/resources issue then if not depending on you, and you cannot solve it.
You could use try any type of wait implicit/explicit, explicit would throw some exception, but this is not a solution for poor resources.

PhantomJS, but not headless?

Is there a way to get a realtime view of what PhantomJS (or similar) is rendering?
I would like to develop my automation script while interacting with (or at least seeing a screencap of) the page it's targeted to.
No, there is no such thing. SlimerJS has the same API as PhantomJS, but runs the Gecko engine. You can see directly what is going on and run it headlessly with xvfb-run.
You will not be able to interact with it. You may want to use a screengrabber to record a video of the interaction when the tests are long and you don't want to run the test suite again if you didn't catch the problem in the test case.
The obvious way to debug PhantomJS scripts is to render many screenshots using page.render() and logging some objects to the console with
console.log(JSON.stringify(yourObj, undefined, 4));
with nice formatting.
Solution we use is an automatic screenshoting in case of exceptions, phantomJs will render the current page into a file that you can exam later .
That's for test execution phase.
When you writing the tests, just keep additional window open ("normal browser") with the application you trying to test and design the test according to it.
When the design is done, execute the test with phantomJS.
My Suggestion is to use logging alongside.
http://casperjs.org/
CasperJS is an open source navigation scripting & testing utility written in Javascript for the PhantomJS WebKit headless browser and SlimerJS (Gecko). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks such as:
defining & ordering browsing navigation steps
filling & submitting forms
clicking & following links
capturing screenshots of a page (or part of it)
testing remote DOM
logging events
downloading resources, including binary ones
writing functional test suites, saving results as JUnit XML
scraping Web contents
The solution to this problem is using the remote debugger:
--remote-debugger-port=9000
Using slimerjs for testing scripts with a browser is not advisable since it is based on gecko, which means the script might work on slimerjs and not on phantomjs or viceversa.
take a look at this guide for more info...
https://drupalize.me/blog/201410/using-remote-debugger-casperjs-and-phantomjs

Web Consistency Testing & Selenium : is there any tool which we can integrate with selenium to perform Web consistency testing

Web Consistency Testing & Selenium : is there any tool which we can integrate with selenium to perform Web consistency testing
I can do this using Selenium but its scope is limited using getallButtons, getAllFields etc. but it does not fetch all Page elements and also it only fetches only buttons or labels not every GUI element which are actually causing problems
So is there any Web consistency tool which can(prefered) or can not be integrated with selenium?
Also please suggest any others ways you know to perform this without selenium or with selenium
Mogotest is the tool designed for this testing. It is commercial though.
http://webconsistencytesting.com/
Theoretically you can obtain all page elements with Web Driver using xpath search
List<WebElement> elements = driver.findElements(By.xpath("//*"));
But processing those elements is so slow that renders this method virtually useless. Assuming you would like to invoke WebDriver's getTagName(), getLocation() and getSize() methods on every element of the web page it would take average 10 seconds (measured for a page with 190 elements which is relatively small).
If time is important for you, you need to go for difficult method which is serializing DOM to JSON or XML using javascript (you can inject javascript with Web Driver) and then parsing it in whatever language you're using for writing your Selenium tests.

JMeter Tests and Non-Static GET/POST Parameters

What's the best strategy to use when writing JMeters tests against a web application where the values of certain query-string and post variables are going to change for each run.
Quick, common, example
You go to a Web Page
Enter some information into a form
Click Save
Behind the scenes, a new record is entered in the database
You want to edit the record you just entered, so you go to another web page. Behind the scenes it's passing the page a parameter with the Database ID of the row you just created
When you're running step 5 of the above test, the page parameter/Database ID is going to change each time.
The workflow/strategy I'm currently using is
Record a test using the above actions
Make a note of each place where a query string variable may change from run to run
Use a XPath or Regular Expression Extractor to pull the value out of a response and into a JMeter variable
Replace all appropriate instances of the hard-coded parameter with the above variable.
This works and can be automated to an extent. However, it can get tedious, is error prone, and fragile. Is there a better/commonly accepted way of handling this situation? (Or is this why most people just use JMeter to play back logs? (-;)
Sounds to me like your on the right track. The best that can be achieved by JMeter is to extract page variables with a regular expression or xpath post processor. However your absolutely correct in that this is not a scalable solution and becomes increasingly tricky to maintain or grow.
If you've reached is point then you may want to consider a tool which is more specialised for this sort of problem. Have a look web testing tool such as Watir, it will automatically handle changing post parameters; but you would still need to extract parameters if you need to do a database update but using Watir allows for better code reuse making the problem less painful.
We have had great success in testing similar scenarios with JMeter by storing parameters in JMeter Variables within a JDBC assertion. We then do our http get/post and use a BSF Assertion and javascript do complex validation of the response. Hope it helps