how to change page load timeout?

420 views
Skip to first unread message

Sanjay Giri

unread,
Jun 22, 2023, 2:53:12 AM6/22/23
to Geb User Mailing List
hello everyone,

From this link


under Page Load Timeout it says the default wait is 300000.

I wanted to change the page load timeout to just 2 minutes. how can i make this change?

I am using GEB in grails 4 as functional test.

This is my GebConfig.groovy

import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.FirefoxDriver

environments {

// run via “./gradlew -Dgeb.env=chrome iT”
chrome {
driver = {

System.setProperty('webdriver.chrome.driver', 'C:\\webdrivers\\chromedriver.exe')
new ChromeDriver()
}

}

// run via “./gradlew -Dgeb.env=chromeHeadless iT”
chromeHeadless {
driver = {
ChromeOptions o = new ChromeOptions()

o.addArguments('headless')
new ChromeDriver(o)
}
}

// run via “./gradlew -Dgeb.env=firefox iT”
firefox {
driver = { new FirefoxDriver() }
}
}


I appreciate any help! Thanks!

Alexander Kriegisch

unread,
Jun 22, 2023, 3:18:28 AM6/22/23
to geb-...@googlegroups.com
I have not tried, but it could be something like:

driver = {
ChromeOptions o = new ChromeOptions()
o.addArguments('headless')
def chromeDriver = new ChromeDriver(o)
chromeDriver.manage().timeouts().pageLoadTimeout(2, TimeUnit.MINUTES)
chromeDriver
}

Marcin will correct me, if necessary. 😉

--
Alexander Kriegisch
https://scrum-master.de
> --
> You received this message because you are subscribed to the Google
> Groups "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to geb-user+u...@googlegroups.com
> <mailto:geb-user+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/3b9b548a-4508-4ee0-94c0-cdc1c63a0cd0n%40googlegroups.com <https://groups.google.com/d/msgid/geb-user/3b9b548a-4508-4ee0-94c0-cdc1c63a0cd0n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Sanjay Giri

unread,
Jun 22, 2023, 3:42:14 AM6/22/23
to Geb User Mailing List
thank you very much. Few times i am receiving 

timed out receiving message from renderer 300.000 

error. 

do you know what is causing this and how to overcome it?

In the setup i have put


def setup() {

driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);


}

but it doesnt seem to work. 

Alexander Kriegisch

unread,
Jun 22, 2023, 4:14:06 AM6/22/23
to geb-...@googlegroups.com
A complete, minimal reproducer would be helpful. Please also share the
full stack trace of your error. Thank you.
--
Alexander Kriegisch
https://scrum-master.de


Sanjay Giri schrieb am 22.06.2023 um 09:42:
> thank you very much. Few times i am receiving 
>
> timed out receiving message from renderer 300.000 
>
> error. 
>
> do you know what is causing this and how to overcome it?
>
> In the setup i have put
>
>
> def setup() {
>
> driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
>
>
> }
>
> but it doesnt seem to work. 
>
> On Thursday, June 22, 2023 at 1:03:28 PM UTC+5:45 alex...@kriegisch.name
> wrote:
>
> I have not tried, but it could be something like:
>
> driver = {
> ChromeOptions o = new ChromeOptions()
> o.addArguments('headless')
> def chromeDriver = new ChromeDriver(o)
> chromeDriver.manage().timeouts().pageLoadTimeout(2, TimeUnit.MINUTES)
> chromeDriver
> }
>
> Marcin will correct me, if necessary. 😉
>
> --
> Alexander Kriegisch
> https://scrum-master.de <https://scrum-master.de>
> https://groups.google.com/d/msgid/geb-user/3b9b548a-4508-4ee0-94c0-cdc1c63a0cd0n%40googlegroups.com <https://groups.google.com/d/msgid/geb-user/3b9b548a-4508-4ee0-94c0-cdc1c63a0cd0n%40googlegroups.com> <https://groups.google.com/d/msgid/geb-user/3b9b548a-4508-4ee0-94c0-cdc1c63a0cd0n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/geb-user/3b9b548a-4508-4ee0-94c0-cdc1c63a0cd0n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to geb-user+u...@googlegroups.com
> <mailto:geb-user+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/9bbd5b3e-6339-4ebf-a36f-e5fdc69915f1n%40googlegroups.com <https://groups.google.com/d/msgid/geb-user/9bbd5b3e-6339-4ebf-a36f-e5fdc69915f1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Sanjay Giri

unread,
Jul 3, 2023, 10:08:48 PM7/3/23
to Geb User Mailing List
this is the code.  This is files downloader program.

I read bunch of urls from a file which i want to download. then i loop through the links and visit the link and click on download button. the waituntilfiledownloads function checks the downloads folder and sees if there are any active crdownload files which means the file is currently downloading so it pauses. 

I am receiving error of this nature. https://stackoverflow.com/questions/48450594/selenium-timed-out-receiving-message-from-renderer


@Integration
class DownloadSpec extends GebSpec {

    def setup() {


    }

    def cleanup() {
    }



    private void waitUntilFileDownloads(){
        def complete = false


        def dh = new File('C:\\Users\\User\\Downloads')


        while(!complete){

            def downloading = []

            dh.eachFile {

                if(it.toString().contains("crdownload")){

                    downloading.add(it)

                }

            }

            if(downloading.size() == 0){
                complete = true
            }else{
                Thread.sleep(10000)
            }

        }
    }

    void "download vimm"() {
        when:"The home page is visited"

        def list = new File("games.txt").readLines()


        for(url in list){

                go url
                println "Downloading " + url


                    $("#download_form > button").click()
                    Thread.sleep(2000)
                    waitUntilFileDownloads()
           

        }


        then:"The title is correct"
            println "Completed!"
    }
}



Alexander Kriegisch

unread,
Jul 4, 2023, 3:53:25 AM7/4/23
to geb-...@googlegroups.com

Hi Sanjay!

Your Geb spec is not really a test but a download tool. I guess you want to do something like this, given an input file src/test/resources/games.txt like this:

Then I would do what you want like this:
package de.scrum_master.geb_ml import geb.spock.GebSpec import spock.lang.Unroll import java.nio.file.DirectoryStream import java.nio.file.Files import java.nio.file.Path class ConsoleGamesDownloadIT extends GebSpec { static Path downloadFolder = new File("${System.getenv('USERPROFILE')}\\Downloads").toPath() @Unroll def "download #url"() { given: 'visiting download page' go url and: 'clicking cookie banner, if necessary' $('button.css-47sehv').click() and: 'determining the current number of matching files in the download directory' def archiveName = $('#data-good-title').text().replace('.nes', '') DirectoryStream<Path> dirBeforeDownload = Files.newDirectoryStream(downloadFolder, "$archiveName*.zip") def filesFoundBeforeDownload = dirBeforeDownload.size() dirBeforeDownload.close() when: 'clicking download button' $("#download_form > button").click() then: 'wait for download completion' waitFor 30, 1, { def dirAfterDownload = Files.newDirectoryStream(downloadFolder, "$archiveName*.zip") def filesFoundAfterDownload = dirAfterDownload.size() dirAfterDownload.close() filesFoundAfterDownload > filesFoundBeforeDownload } where: url << new File("src/test/resources/games.txt").readLines() } }
This does not answer your question, but at least it is a reproducible example (which would have been your job to provide, like I asked you to before), and we can take it from here, if this code still yields the same problems as before.

Alexander Kriegisch
https://scrum-master.de
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/1a73a51c-d021-45aa-97bf-11cff20d4b49n%40googlegroups.com.

Alexander Kriegisch

unread,
Jul 4, 2023, 4:02:14 AM7/4/23
to geb-...@googlegroups.com

Sorry, I accidentally sent a slightly older version of the Geb spec than I intended to. Here is a refactored version:

package de.scrum_master.geb_ml import geb.spock.GebSpec import spock.lang.Unroll import java.nio.file.Files import java.nio.file.Path class ConsoleGamesDownloadIT extends GebSpec { static Path downloadFolder = new File("${System.getenv('USERPROFILE')}\\Downloads").toPath() @Unroll def "download #url"() { given: 'visit download page' go url and: 'click cookie banner' $('button.css-47sehv').click() and: 'determine the current number of matching files in the download directory' def archiveName = $('#data-good-title').text().replace('.nes', '') def filesFoundBeforeDownload = numberOfMatchingFiles("$archiveName*.zip") when: 'clicking download button' $("#download_form > button").click() then: 'wait for download completion' waitFor 30, 1, { numberOfMatchingFiles("$archiveName*.zip") > filesFoundBeforeDownload } where: url << new File("src/test/resources/games.txt").readLines() } int numberOfMatchingFiles(String globPattern) { def directoryStream = Files.newDirectoryStream(downloadFolder, globPattern) def numberOfFilesFound = directoryStream.size() directoryStream.close() numberOfFilesFound } }

Alexander Kriegisch
https://scrum-master.de

Sanjay Giri

unread,
Jul 4, 2023, 5:24:57 AM7/4/23
to Geb User Mailing List
thank you very much. ill try and see if it works. 
Message has been deleted

Alexander Kriegisch

unread,
Jul 5, 2023, 1:44:39 AM7/5/23
to geb-...@googlegroups.com

Sorry Sanjay, but is it so difficult to spot the places where you need to change the code? This mailing list is no free version of Upwork where people do your job for you. I was just being friendly the first time, rewriting your code and even guessing which website you want to download from, trying to get you started. Anyway, a few pointers:

Firstly, if you download the PS1 games manually, it looks like they are *.7z archives instead if *.zip. Therefore, change this line:

def filesFoundBeforeDownload = numberOfMatchingFiles("$archiveName*.7z") ^^

Secondly, the downloads are way bigger and possibly need more than 30 seconds to download, i.e. you could e.g. wait 5 minutes (300 seconds) here:

then: 'wait for download completion' waitFor 120, 1, { numberOfMatchingFiles("$archiveName*.7z") > filesFoundBeforeDownload }

Please note that again, I have changed the file extension to "7z". It should be very easy to change the numberOfMatchingFiles helper methods in such a way as to check for both ".7z "and ".zip" files and call it without the extension in the archive name. I leave that as a little homework to you in order to understand the code better. 🙂

Regards

Alexander Kriegisch
https://scrum-master.de

Sanjay Giri schrieb am 05.07.2023 um 02:53:
looks like this script is doing what i am trying to do. 

could you please modify the code and share so that it works for ps1 games. 


lets say there are three links in the games.txt file. 


vimm doesnt allow multiple downloads so we need to wait until one download completes. the program should download the next file automatically after the first one downloads. 

could you please share the program code? i appreciate it a lot. 

Thank you!

Sanjay Giri

unread,
Jul 5, 2023, 2:08:10 AM7/5/23
to Geb User Mailing List
thanks!

Sanjay Giri

unread,
Jul 7, 2023, 3:18:34 AM7/7/23
to Geb User Mailing List
hi alex, it seems like this line

go url

hangs sometimes. is there a way to timeout and not wait forever? if that is possible, that will solve the problem. Thanks!

Alexander Kriegisch

unread,
Jul 7, 2023, 4:05:53 AM7/7/23
to geb-...@googlegroups.com

I never experienced that problem while testing this. Your error description is a bit fuzzy, too. I do not even know if the problem occurs in Chrome, Firefox, headless or with normal browser. Therefore, I cannot easily help you. Maybe it would be a good idea to create a page class with an 'at' checker and cleanly defined page elements (navigators). If you are able to more precisely describe what is going wrong and why you think 'go' hangs, maybe I can give you better advice.

Alexander Kriegisch
https://scrum-master.de
Reply all
Reply to author
Forward
0 new messages