How to wait for page load in selenium webdriver - selenium-webdriver

I am using selenium-server-3.7.1 and Firefox 57
How to wait for page to load completely
I tried following
return ((JavascriptExecutor) driver).executeScript(
"return document.readyState").equals("complete");
but it is not working
Basically the above command is not recognizing below operations
[testng] 1535139249496 addons.productaddons INFO sending request to: https://aus5.mozilla.org/update/3/GMP/57.0.4/20180103231032/Linux_x86_64-gcc3/en-US/release/Linux%204.1.12-112.14.10.el7uek.x86_64%20(GTK%203.22.10%2Clibpulse%2010.0.0)/default/default/update.xml
[testng] 1535139249669 addons.productaddons INFO Completed downloading document
[testng] 1535139249818 addons.productaddons INFO downloadXHR File download. status=200
[testng] 1535139249821 addons.productaddons INFO Downloaded file will be saved to /tmp/tmpaddon-c61a84
[testng] 1535139738375 addons.manager INFO Skipping background update check
[testng] 1535139978387 DeferredSave.extensions.json DEBUG Save changes
[testng] 1535139978387 DeferredSave.extensions.json DEBUG Starting timer
[testng] 1535139978409 DeferredSave.extensions.json DEBUG Starting write
[testng] 1535139978412 DeferredSave.extensions.json DEBUG Write succeeded
I gave hard sleep of 30 seconds to finish these operations
Is there a way to wait for these operations to be completed?

In Automation script, There needs to wait on multiple instance. There can not be use Thread.Sleep(); every time. Page need to wait for JQuery, JavaScript, Angular loading. And which can not be handle by only document.readyState We have to wait for all substances if application is built on. So, We can create single method to wait for Page load and that method can call multiple times.
This is the Blog link for same, Which will help you to understand it. Click Here
You can include those method, on which your application is build.
If in case Blog link might loss, there is sample Github project is available for same. Click Here

Wait wait = new FluentWait(driver)
.withTimeout(30000, TimeUnit.SECONDS) .pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class);
Hope this will help you

Related

Unable to run test in Flow Designer

I am going through MuleSoft's "Development Fundamentals (Mule 4)" and I'm doing one of the walkthroughs - "WT 2-3: Create an integration application with Flow Designer that consumes an API" and on one of the steps (step 23) the test button does not run and consequently, I can't test the REST endpoint, because I don't have a URL to send requests to.
When I click the Test button, it switches to "Refresh" and on the left of the button it says "Project needs to be refreshed".
However, when I click the Refresh button and wait several minutes for the refresh, it goes back to the Test button, which again doesn't work and shows "Project needs to be refreshed" when clicked, so I am stuck in this endless loop.
I tried deleting everything I had done up to that point and started again from scratch, but when I reached that walkthrough again, I had the same problem.
The only things I have in the Flow Designer are an HTTP Listener and "American Flights API". The problem occurs after I add the API. Before I added in the API, I successfully ran the test with an HTTP Listener and a logger.
The HTTP Listener configuration:
path : flights
The "American Flights API" configuration:
host : training4-american-api.cloudhub.io
port : 80
base path : /
protocol : HTTP
The log in the Runtime Manager shows a LifecycleException, but I don't know what is causing it or how to prevent it.
Here is the log from the Runtime Manager:
[2021-08-22 14:56:32.872] INFO com.mulesoft.ch.queue.boot.PersistentQueueCoreExtension [qtp1112210076-38]: The PersistentQueueManager is NOT configured. The normal VM queue manager will be used.
[2021-08-22 14:56:40.483] INFO org.mule.runtime.api.el.AbstractBindingContextBuilderFactory [qtp1112210076-38]: Loaded BindingContextBuilderFactory implementation 'org.mule.runtime.core.api.el.DefaultBindingContextBuilderFactory' from classloader 'org.mule.runtime.module.reboot.internal.MuleContainerSystemClassLoader#740e48c1'
[2021-08-22 14:56:40.874] INFO org.mule.runtime.core.internal.util.journal.TransactionJournal [qtp1112210076-38]: Using files for tx logs /opt/mule/mule-4.3.0/./.mule/americanflightsapp-xslg/queue-tx-log/tx1.log and /opt/mule/mule-4.3.0/./.mule/americanflightsapp-xslg/queue-tx-log/tx2.log
[2021-08-22 14:56:40.882] INFO org.mule.runtime.core.internal.util.journal.TransactionJournal [qtp1112210076-38]: Using files for tx logs /opt/mule/mule-4.3.0/./.mule/americanflightsapp-xslg/queue-xa-tx-log/tx1.log and /opt/mule/mule-4.3.0/./.mule/americanflightsapp-xslg/queue-xa-tx-log/tx2.log
[2021-08-22 14:56:41.137] INFO com.mulesoft.ch.batch.BatchCoreExtension [qtp1112210076-38]: Persistent queues is not enabled for batch module as it was not configured in Cloudhub console
[2021-08-22 14:56:41.168] INFO org.mule.runtime.core.internal.util.queue.QueueXaResourceManager [ArtifactDeployer.start.01]: Starting ResourceManager
[2021-08-22 14:56:41.169] INFO org.mule.runtime.core.internal.util.queue.QueueXaResourceManager [ArtifactDeployer.start.01]: Started ResourceManager
[2021-08-22 14:56:41.207] INFO org.mule.runtime.core.internal.logging.LogUtil [ArtifactDeployer.start.01]:
**********************************************************************
* Application: americanflightsapp-xslg *
* OS encoding: UTF-8, Mule encoding: UTF-8 *
* *
**********************************************************************
[2021-08-22 14:59:47.852] INFO org.mule.runtime.core.internal.util.queue.QueueXaResourceManager [qtp1112210076-39]: Stopping ResourceManager
[2021-08-22 14:59:47.852] INFO org.mule.runtime.core.internal.util.queue.QueueXaResourceManager [qtp1112210076-39]: Stopped ResourceManager
[2021-08-22 14:59:47.867] INFO org.mule.runtime.core.internal.lifecycle.RegistryLifecycleCallback [qtp1112210076-39]: Failure executing phase stop over object DefaultBatchEngine, error is: org.mule.runtime.api.lifecycle.LifecycleException(Failed to invoke lifecycle phase "stop" on object: com.mulesoft.mule.runtime.module.batch.internal.engine.DefaultBatchEngine#2fd96fde)
[2021-08-22 14:59:47.869] INFO org.mule.runtime.module.deployment.impl.internal.artifact.AbstractDeployableArtifact [qtp1112210076-39]: Stopping app 'americanflightsapp-xslg' with no mule context
[2021-08-22 14:59:47.922] INFO org.mule.runtime.core.internal.logging.LogUtil [qtp1112210076-39]:
**********************************************************************
* Application "americanflightsapp-xslg" shut down normally on: *
* 8/22/21 2:59 PM *
* Up for: 0 days, 0 hours, 3 mins, 6.753 sec *
**********************************************************************
Any help is welcome, thank you.
The problem was coming from MuleSoft's side. I reported the problem on their Help Center and got a response that the issue was under investigation. Several days later, the problem was fixed and the Test button on the Flow Designer page is now working correctly.

JMeter execution does not stops when using WebDriver

I'm using latest JMeter 3.3 to run a latest Selenium WebDriver test, everything seems to be OK,
I only have 1 thread configured with 1 sec ramp up and 1 loop count, however after the webdriver execution is completed, JMeter does not stops the overall test execution and keeps on executing the test for infinity, I'm not sure why is that happening, I'm using chromedriver and all the configuration I have done is as per jmeter documentation, I have also added WDS.sampleResult.sampleEnd() command at the end of my script. Please refer screenshots attached -
Thread Group -
I just want as soon as my sample ends, JMeter test execution should also stop.
There is a problem in your configuration as per the bug report you made:
https://bz.apache.org/bugzilla/show_bug.cgi?id=61661
You have the below exception occurring which is due to missing jar that contains:
com/sun/jna/platform/win32/Kernel32
So download it with it dependencies put it in jmeter/lib folder.
You can find it here:
http://www.java2s.com/Code/Jar/j/Downloadjna330platformjar.htm
http://www.java2s.com/Code/Jar/j/Downloadjna330jar.htm

angular fullstack generator grunt serve ERR_CONNECTION_REFUSED

I'm building a project on a yeoman angular-fullstack generator. It's been a quite a while and the landing page was correctly loading after running grunt serve task.
I really don't know what I've done but now when I run grunt serve I see ERR_CONNECTION_REFUSED message in chrome first and then the landing page loads normally(about 5 seconds after ERR_CONNECTION_REFUSED message)
This makes my e2e tests crash.
found some issues on github about grunt-concurrent downgrading and disabling livereload but nothing helps..
This is the log. As you see express server has to start listening before open server and watch tasks( newly created fullstack-generator does that so it works correctly)
Running "serve" task
Running "clean:server" (clean) task
>> 1 path cleaned.
Running "env:all" (env) task
Running "concurrent:pre" (concurrent) task
Running "ngconstant:app" (ngconstant) task
Creating module serviceboxApp.constants at client/app/app.constant.js...OK
Done, without errors.
Execution Time (2016-02-26 00:40:08 UTC)
loading tasks 302ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85%
loading grunt-ng-constant 34ms ▇▇▇▇ 10%
ngconstant:app 19ms ▇▇ 5%
Total 356ms
Running "concurrent:server" (concurrent) task
Running "newer:babel:client" (newer) task
Running "babel:client" (babel) task
Running "newer-postrun:babel:client:1:/Users/apple/Desktop/dev/servicebox/node_modules/grunt-newer/.cache" (newer-postrun) task
Done, without errors.
Execution Time (2016-02-26 00:40:09 UTC)
loading tasks 312ms ▇▇▇▇▇▇▇ 15%
newer:babel:client 36ms ▇ 2%
loading grunt-babel 415ms ▇▇▇▇▇▇▇▇▇ 20%
babel:client 1.2s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 61%
Total 2s
Running "injector:scripts" (injector) task
Missing option `template`, using `dest` as template instead
Injecting js files (33 files)
Running "injector:css" (injector) task
Missing option `template`, using `dest` as template instead
Injecting css files (9 files)
Running "wiredep:client" (wiredep) task
Running "postcss:dist" (postcss) task
Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
[TypeError: Cannot read property 'Kerberos' of undefined]
Running "wait" task
>> Waiting for server reload...
Done waiting!
Running "open:server" (open) task
Running "watch" task
Waiting...
Express server listening on 9000, in development mode
finished populating users
finished populating quotes
finished populating poviders
You have TypeError that is preventing your code from running properly. [TypeError: Cannot read property 'Kerberos' of undefined]
You don't know JS explains that a TypeError "implies that Scope resolution was successful, but that there was an illegal/impossible action attempted against the result."
So you need to go back to where you are calling Kerberos and resolve the TypeError

Android build fails in codenameone build sever

My android build fails after build and this is the error log i get
Total time: 1 mins 16.631 secs
Stopped 0 compiler daemon(s).
Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':dexRelease'.] from daemon DaemonInfo{pid=5907, address=[10331ba5-2501-41cc-aa13-52a0ba46bd51 port:41817, addresses:[/0:0:0:0:0:0:0:1%1, /127.0.0.1]], idle=false, context=DefaultDaemonContext[uid=2862cb6d-50e8-4321-a1fa-590435e89f0f,javaHome=/usr/java/jdk1.7.0_67,daemonRegistryDir=/home/ec2-user/.gradle/daemon,pid=5907,idleTimeout=120000,daemonOpts=-XX:MaxPermSize=512m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1500m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
This is probably related to this: https://www.codenameone.com/blog/video-new-defaults-barcode-qrcode-changes.html
You can workaround this by using android.gradle=false in the build hints. However, I'm guessing its related to some cn1lib or build hint you added. But it seems the build error log you provided is partial so I don't see any issue there.

Grunt is insanely slow on a clean yeoman angular-generate setup

I'm a grunt newbie. My PC runs Windows 7 x64.
I followed the Yeoman tutorial (on the Yeoman site) and I did not change anything in any of the generated files. Then, I ran
grunt serve
When I change any html file, the grunt process is instantaneous, but when I modify one of the .js or .css files, the process is insanely slow. When I hit save, grunt notices it immediately :
>> File "app\styles\index.css" changed
But there seems to be around 4 long seconds before the next lines appear on the terminal :
Running "newer:copy:styles" (newer) task
Running "copy:styles" (copy) task
Copied 1 files
Running "newer-timestamp:copy:styles:R:\Personnel\Workspaces\web\front\plume\node_modules\grunt-newer\.cache" (newer-timestamp)
task
Running "newer-reconfigure:copy:styles:1" (newer-reconfigure) task
Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/index.css" created.
Prefixed file ".tmp/styles/main.css" created.
Done, without errors.
Execution Time (2014-03-21 00:00:19 UTC)
loading tasks 6ms ■■■■■ 9%
newer:copy:styles 9ms ■■■■■■■■ 14%
copy:styles 7ms ■■■■■■ 11%
newer-timestamp:copy:style...odules\grunt-newer\.cache 3ms ■■■ 5%
autoprefixer 1ms ■ 2%
autoprefixer:dist 39ms ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 59%
Total 66ms
... Reload .tmp\styles\index.css ...
... Reload .tmp\styles\main.css ...
Completed in 4.463s at Fri Mar 21 2014 01:00:20 GMT+0100 (Paris, Madrid) -
Waiting...
I'm confused. grunt says it took him 66ms total to run the tasks, but then it says that it took him 4.463s to complete the whole process.
What did I did wrong ? The build is clean, I did nothing else than
yo angular
To scaffold the app... Any idea ?
edit :
spawn: false
Solved my problem. Thanks to the one who brought that up. Even if I use Gulp or webpack nowadays.
There is a spawn option that sometimes make things faster --and also more prone to failing apparently.
From the documentation:
Whether to spawn task runs in a child process. Setting this option to
false speeds up the reaction time of the watch (usually 500ms faster
for most) and allows subsequent task runs to share the same context.
Not spawning task runs can make the watch more prone to failing so
please use as needed.
You would disable the spawn adding a options section inside watch in your Gruntfile.js. Something like this.
watch: {
options: {
spawn: false
},

Resources