Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 24 23:18
    asolntsev synchronize #1490
  • Jun 24 23:18

    asolntsev on reproduce-flaky-click-relative-test

    add logging (compare)

  • Jun 24 22:50
    asolntsev converted_to_draft #1490
  • Jun 24 22:50
    asolntsev opened #1490
  • Jun 24 22:40

    asolntsev on reproduce-flaky-click-relative-test

    reproduce flaky ClickRelativeTe… (compare)

  • Jun 24 18:46

    asolntsev on master

    improve test `matchText` was n… (compare)

  • Jun 24 09:50

    asolntsev on add-support-for-okhttp4

    (compare)

  • Jun 24 09:50

    asolntsev on master

    add support for okhttp 4.9.1 *… (compare)

  • Jun 24 09:50
    asolntsev closed #1488
  • Jun 24 09:49

    asolntsev on add-task-to-publish-jar

    (compare)

  • Jun 24 09:49

    asolntsev on master

    fix command `./gradlew` - now i… (compare)

  • Jun 24 09:49
    asolntsev closed #1489
  • Jun 22 23:34
    asolntsev milestoned #1489
  • Jun 22 23:34
    asolntsev review_requested #1489
  • Jun 22 23:34
    asolntsev assigned #1489
  • Jun 22 23:34
    asolntsev opened #1489
  • Jun 22 23:33

    asolntsev on add-task-to-publish-jar

    fix command `./gradlew` - now i… (compare)

  • Jun 22 23:32
    asolntsev review_requested #1488
  • Jun 22 23:16
    asolntsev milestoned #1488
  • Jun 22 23:16
    asolntsev labeled #1488
Andrey Kolesnyk
@trugaaa
Gradle.kts
tasks.withType<Test> {
    testLogging {
        showExceptions = true
        exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
        ignoreFailures = true
        reports.html.isEnabled = false
    }
    useTestNG {
        //listeners.add("listeners.TestListener")
        suiteXmlFiles.add(File("src/test/resources/testng.xml"))
    }
    //Allure results folder can be also set here but then allure.properties file is necessary for separate test allure results
    //See - https://github.com/allure-framework/allure-java/issues/505
    //System.setProperty("allure.results.directory", "$buildDir/allure-results")
}

task<Test>("chrome") {
        System.setProperty("selenide.browser", "chrome")
}

task<Test>("firefox") {
        System.setProperty("selenide.browser", "firefox")
}
When I use command gradle clean firefox
tests opens in chrome browser it seems like sys prop is not checked by selenide conf or smth
also command gradle clean test -Dselenide.browser=firefox doesnt work
Andrei Solntsev
@asolntsev
@trugaaa To previous question:
  1. you still can run cross-browser tests with one task, if you fork parallel tests (run tests in parallel processes, not threads)
  2. You can even use different browsers inside the same JVM with help of SelenideDriver, see https://selenide.org/2018/10/10/selenide-5.0.0/
  3. There is a feature request to make Configuration.browser thread-local instead of static: selenide/selenide#1372 (not implemented yet)
About your gradle script:
  1. You need to run gradlew firefox, not gradle clean test -Dselenide.browser=firefox
  2. The problem is that gradle and tests are executed in different JVMs.
    Instead of System.setProperty("selenide.browser", "firefox”) (which sets system property to gradle itself), you need systemProperties['selenide.browser'] = ‘firefox’ (which sets system property to the tests JVM).
Andrey Kolesnyk
@trugaaa
Thanks a lot!
I will try it tomorrow, hopes that with gradle dsl it will work fine
Andrey Kolesnyk
@trugaaa
It worked! thanks a lot!
Madhu Palagani
@MadhuPalagani_twitter
Hi Team,
executeJavaScript("return dataLayer.length") - working fine
executeJavaScript("return dataLayer") is returning stale element exception. any work around plz
Andrei Solntsev
@asolntsev
Hi. It seems your question is not related to Selenide.
Oser
@MarsOu1998
Hi,Why use Selenide to download file will generate a folder,I dont want it,please help.
image.png
my pom.xml
        <!-- https://mvnrepository.com/artifact/com.codeborne/selenide -->
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>5.19.0</version>
        </dependency>
Andrei Solntsev
@asolntsev
@MarsOu1998 Selenide generates unique folders for downloading files to be sure that none of previously downloaded files can affect current test.
@MarsOu1998 Can you describe why it’s not ok? Most probably I have a better solution for your problem.
Oser
@MarsOu1998
Thanks for repley,I switch the selenide version to 5.13.1 , everything is back to normal. :)
@asolntsev Actually,I use selenide to download files and use java to open files to do data validation,if Selenide generates folders, the program cant find the files.
Oser
@MarsOu1998
Is there a way to get the foldername the Selenide generates? I want to use the latest version of Selenide.
Andrei Solntsev
@asolntsev
@MarsOu1998 As I assumed, you are trying re-invent the bycycle.. :)
@MarsOu1998 Good news: you can simplify your code.
You don’t really need to search the downloaded file in any folders. Method $.download() returns an instance of File. This is the downloaded file. No matter what folder it’s downloaded to. You can open this file.
Something like
File theDownloadedFile = $(“input#cv”).download();
PDF pdf = new PDF(theDownloadedFile);
assertThat(pdf, containsText(“expected text here…”);
Oser
@MarsOu1998
It's glad to see your reply . Actually, I tried the way you provided yesterday , but we use js method( onClick() ) to download file
image.png
my code:
        File file = $("#mainDiv > div:nth-child(2) > div:nth-child(5) > a").download();
Here is the error:
Message: java.lang.IllegalArgumentException: The element does not have href attribute: <a class="image_button" onclick="ECUExcel()" type>Export</a>
Andrei Solntsev
@asolntsev
Ok, then try to set Configuration.fileDownload = FOLDER; somewhere in the beginning of your tests.
Oser
@MarsOu1998
Thanks, I just tried, but it doesnt seem work ,it still generates a folder even if I specify a filea path
        Configuration.fileDownload = FOLDER;
        Configuration.downloadsFolder="tests";
        Configuration.startMaximized = true;
        Configuration.timeout = 20000;
        System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
        Configuration.browser = "chrome";
image.png
image.png
image.png
Andrei Solntsev
@asolntsev
@MarsOu1998 Once again, it MUST generate folder. It’s ok. You just don’t need to search any files in any folders. Just use the returned File.
Oser
@MarsOu1998
Sorry, I dont get it.When I download a file ,it will be stored on my computer disk, if I want to open it, shouldn't I specify the path?
What does "returned File" mean
Andrei Solntsev
@asolntsev
No, you shouldn’t specify any paths.
Once again:
    File file = $("#mainDiv > div:nth-child(2) > div:nth-child(5) > a").download();
    //    … this “file" is your downloaded file. No need to search it anywhere.

    // for example, you can read it:
    try (FileReader in = new FileReader(file)) {

    }

   // or get its full path:
   String path = file.getAbsolutePath();
Oser
@MarsOu1998
OMG!!It works!! You are the best person I've ever met!! Thanks for your help and sorry to bother you for so long.
Andrei Solntsev
@asolntsev
Thank you :)
Oser
@MarsOu1998
It's late at night in China, wish you a good dream tonight.
Andrei Solntsev
@asolntsev
Yes, it’s the goal of Selenide: to solve all generic technical details for you, so that you could focus on your project-specific business logic.
Oser
@MarsOu1998
ok,love u
Andrei Solntsev
@asolntsev

We released Selenide 5.20.1: "Mmm hmm, a killer feature!”

https://selenide.org/2021/03/23/selenide-5.20.1/

tann200
@tann200
Hey, how would I make sure, that selenide doesn't share session over tests?
I had to turn off parallel exections, because I had similar tests running and one test got sso session from the other test :D
Andrei Solntsev
@asolntsev
Hi @tann200 .