Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 07:50
    Tonicku commented #1297
  • 07:49
    Tonicku commented #1297
  • Aug 01 21:14
    asolntsev closed #1297
  • Aug 01 21:14
    asolntsev commented #1297
  • Aug 01 11:10
    long5192004 closed #1514
  • Aug 01 11:10
    long5192004 edited #1514
  • Aug 01 11:09
    long5192004 edited #1514
  • Aug 01 10:14
    long5192004 edited #1514
  • Aug 01 10:06
    asolntsev labeled #1514
  • Aug 01 09:01
    long5192004 edited #1514
  • Aug 01 08:55
    long5192004 opened #1514
  • Jul 30 09:13
    bereg2k edited #1511
  • Jul 30 09:12
    bereg2k commented #1511
  • Jul 30 07:55
    bereg2k synchronize #1511
  • Jul 30 06:59

    asolntsev on v5.23.1

    (compare)

  • Jul 30 06:58

    asolntsev on master

    release Selenide 5.23.1 (compare)

  • Jul 30 06:53
    asolntsev closed #1500
  • Jul 30 06:53
    asolntsev commented #1500
  • Jul 30 06:49

    asolntsev on improve-switch-to-frame

    (compare)

  • Jul 30 06:49

    asolntsev on master

    #1500 replace old-style `getCur… #1500 forbid calling `switchTo(… #1500 add unit-tests for the ha… (compare)

Andrei Solntsev
@asolntsev
Ok, I see your “radio” button is not a standard html radio button, but some custom component.
Selenide cannot handle all possible custom components in the world, right?
You can use something like $.shouldHave(cssClass(“mat-radio-checked”)), why not?
You can also create your custom Condition and use it in all your tests:
  public static final Condition matChecked = Condition.cssClass(“mat-radio-checked”);

  $.shouldBe(matChecked);
Arsen Papoyan
@arsen.papoyan:matrix.org
[m]

asolntsev (Andrei Solntsev):
I got you.
We have handled it in this way:

private MyPage radioButtonCheck(SelenideElement element, int index) {
        Checked myChecked = new Checked() {
            @Override
            public boolean apply(Driver driver, WebElement element) {
                String f = String.format("return document.querySelectorAll('[type=radio]')[%s].checked", index);
                return Selenide.executeJavaScript(f);
            }
        };
        element.shouldBe(myChecked);
        return this;
    }

    @Step
    public MyPage depositCheck() {
        depositRadioButton.click();
        radioButtonCheck(depositRadioButton, 0);
        return this;
    }

Now I can use "radioButtonCheck" method for all radio buttons.
What do you think?

Andrei Solntsev
@asolntsev
Well, yes, you can check.
Vlad-Titov
@Vlad-Titov

Not sure if this is a right place to ask but I'm getting following error when I'm trying to run tests
com/codeborne/selenide/Configuration java.lang.NoClassDefFoundError: com/codeborne/selenide/Configuration at configuration.TestBaseClass.SetUpAll(TestBaseClass.java:12) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
Using gradle 7.0 I have following dependencies:

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
    testImplementation 'com.browserup:browserup-proxy-core:2.1.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
    testCompileOnly 'com.codeborne:selenide:5.20.1'
    testCompileOnly 'org.apache.logging.log4j:log4j-api:2.14.1'
    testCompileOnly 'org.apache.logging.log4j:log4j-core:2.14.1'
    testCompileOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1'
}

test {
    useJUnitPlatform()

    reports {
        junitXml.enabled = true
        html.enabled = false
    }
}

Any ideas why it's not being initialized?

Andrei Solntsev
@asolntsev
@Vlad-Titov You need to read all the logs and find the very first error.
Typically NoClassDefFoundError: com/codeborne/selenide/Configuration means that some error happened during the initialization of class Configuration, that’s why JVM could initialize this class. Since then, every call to Configuration throws NoClassDefFoundError.
Vlad-Titov
@Vlad-Titov
Thanks for the answer. The problem was in testCompileOnly 'com.codeborne:selenide:5.20.1', it has to be testImplementation
blick882
@blick882

Hi!
I'm trying to use Selenide for mobile apps(this one is for iOS). Cannot scroll down to the element

    open fun `open login page`(): HowToPage {
        LOGIN_BUTTON.scrollIntoView(true)
        LOGIN_BUTTON.shouldBe(appear)
        LOGIN_BUTTON.click()
        return HowToPage()
    }

It fails and says

Element not found {By.id: Log in}

But the element is clickable and visible to other methods. click() works fine.
How can I just scroll down?

Andrei Solntsev
@asolntsev
@blick882 I guess $.scrollIntoView is web-specific and does not work in mobile apps. You need to Google how to scroll in appium.
Madhu Palagani
@MadhuPalagani_twitter
image.png
Please help me to resolve below
Is it possible to handle (allow/block) the location popup for chrome
By using any configuration setting
Andrei Solntsev
@asolntsev
Afaik you cannot click “Allow” or “Block”.
Instead, you need to enable or disable location by some chrome options when you start a webdriver.
brandonrock919
@brandonrock919

Hi,
I have an issue i want to upload image to website on remote selenoid machine
on selenium this code worked for me

        ((RemoteWebElement) profilePic).setFileDetector(new LocalFileDetector());
        profilePic.sendKeys(profileImage);

but no i dont have idea why its not working
anyone maybe can assist please ?

Andrei Solntsev
@asolntsev
@brandonrock919 Selenide uses the same code by default.
Andrei Solntsev
@asolntsev
Released Selenide 5.21.0: “Say no to duplicates!”
https://selenide.org/2021/05/15/selenide-5.21.0/
brandonrock919
@brandonrock919
@asolntsev maybe there is a issue i tried everything
when i am using selenoid docker with selenide its not uploading the file to the webiste
Andrei Solntsev
@asolntsev
@brandonrock919 You probably open webdriver by yourself?
Andrei Solntsev
@asolntsev
then you need to use LocalFileDetector:
      RemoteWebDriver webDriver = new RemoteWebDriver(toURL("http://localhost:4444/wd/hub"), options);
      webDriver.setFileDetector(new LocalFileDetector());
Boris Osipov
@BorisOsipov
@brandonrock919 also please describe what "its not working" exactly means. can you show error stacktrace?
Sajan
@woodsongem
Hello All,
I creating POC using selenide and trying to implement screenshot and video recored. screenshot is working and not able to find record video. please let me know something wrong in below code.
 ChromeOptions chromeOptions = new ChromeOptions();
            chromeOptions.addArguments("--ignore-ssl-errors=yes", "--ignore-certificate-errors", "--start-maximized");
            chrome = new BrowserWebDriverContainer()
                    .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL,
                            new File("./target/"))
                    .withCapabilities(DesiredCapabilities.chrome())
                    .withCapabilities(chromeOptions);
     if (!chrome.isRunning()) {
                chrome.start();
            }
            RemoteWebDriver driver = chrome.getWebDriver();
            WebDriverRunner.setWebDriver(driver);
Andrei Solntsev
@asolntsev
@woodsongem It seems your question is about TestContainer rather than Selenide.
Though, here you can find some examples of using Selenide with TestContainers: https://github.com/selenide-examples/testcontainers/tree/master/src/test/java/org/selenide/examples
Sajan
@woodsongem
thanks @asolntsev for your response. earlier I refer same repo and not able to identify issue.
one change I tried is new File("build") to new File("./target/")
Sajan
@woodsongem
Hello @asolntsev : how to upload file in Selenide using test container?
Andrei Solntsev
@asolntsev
@woodsongem Exactly the same as any other upload: $(“input”).uploadFile(…);
Sajan
@woodsongem

thanks @asolntsev for your response. I did same and getting below error.

Caused by: InvalidArgumentException: invalid argument: File not found :

file is outside of project and using Selenide with testContainer.

Andrei Solntsev
@asolntsev
It depends on how you create a webdriver. It's important to set LocalFileDetector if you create RemoteWebDriver by yourself.
Sajan
@woodsongem
thanks @asolntsev for your response. I am using BrowserWebDriverContainer and below is the sample code. not sure how to set setFileDetector
ChromeOptions chromeOptions = new ChromeOptions();
            chromeOptions.addArguments("--ignore-ssl-errors=yes", "--ignore-certificate-errors", "--start-maximized");
            chrome = new BrowserWebDriverContainer()
                    .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL,
                            new File("delete"),
                            VncRecordingContainer.VncRecordingFormat.MP4)
                    .withCapabilities(DesiredCapabilities.chrome())
                    .withCapabilities(chromeOptions);
                chrome.beforeTest(new TestDescriptionImpl());
                chrome.start();
Sajan
@woodsongem
thanks @asolntsev . it's worked and took little more time to identify the driver.
chrome.getWebDriver().setFileDetector(new LocalFileDetector());
Andrei Solntsev
@asolntsev
Guys, we have an anniversary release Selenide 5.22.0!
  • #1479 make it possible to check an alert before downloading a file -- see PR #1481
  • #1482 Add support for Condition.textCaseSensitive for selected options in select element -- thanks to Oleg Berezhnoy
  • #1380 Add selectors byTextCaseInsensitive and withTextCaseInsensitive -- see PR #1381
  • #1483 add method Driver.getSessionId() -- thanks to Petro Ovcharenko
  • override default Selenium http timeouts -- see PR #1433
  • #1472 refactoring: pass WebElementSource instead of SearchContext
Vladislav Voronin
@vrnvorona
Hi. I have weird problem with Safari. It won't click, or will click only once and then will throw TimeoutException. Chrome/Firefox is perfect.
Vladislav Voronin
@vrnvorona
Caused by: TimeoutException: at com.codeborne.selenide.ex.UIAssertionError.wrapToUIAssertionError(UIAssertionError.java:83) at com.codeborne.selenide.ex.UIAssertionError.wrapThrowable(UIAssertionError.java:74) at com.codeborne.selenide.ex.UIAssertionError.wrap(UIAssertionError.java:68) at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:90) at com.sun.proxy.$Proxy15.click(Unknown Source)
Andrei Solntsev
@asolntsev

Released Selenide 5.22.0:

Wake up, we have a release again!

https://selenide.org/2021/06/08/selenide-5.22.0/

Kristoffer
@krsg
Hi, I have a problem using source() with Firefox. The web page I'm testing contains some <!-- comments --> right beneath the closing html tag that I need. When using source() with Firefox those comments are missing. It works with Chrome. Does anybody know why they are missing?
Andrei Solntsev
@asolntsev
@krsg As far as I know it’s an expected behaviour. The whole point of comments is the ability to ignore them. Browsers do ignore them. source() can return html without the comments.
@krsg Why do you need to get comments? Usually it’s not needed.
Kristoffer
@krsg
Oh ok, other comments are shown though, but not these under the closing html tag
It's information about the current environment, so we use them to verify that we're in the right test environment and not in production
Andrei Solntsev
@asolntsev
I usually recommend to add such information in `<meta> tags in html.
For example, if you go to https://idemo.bspb.ru you will see build number and revision:
<html>
<head>
  <meta name="build" content="release-2021-03-30-small-stuff.64">
  <meta name="revision" content="ce2afaca56">
Or you can even add a separate URL for such information, like https://your.site.com/info
(It can be disabled in production if it’s not a public info)
Kristoffer
@krsg
Thanks! Sadly I think this is out of my control :-(
The solution works fine with Chrome. I just thought it would be nice to also run the tests with Firefox, that's when I stumbled upon the missing comments. But I think we will manage with just running Chrome.
Thanks for your help :-)
Andrei Solntsev
@asolntsev
Anyway, you can just execute a get request to get the html source. Like
```
String html = IOUtils.readUrlToString("https://your.site.com", UTF8);