Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:17

    asolntsev on fix-dependabot

    (compare)

  • 17:17

    asolntsev on master

    #984 use gradle format accepted… (compare)

  • 17:17
    asolntsev closed #1583
  • 15:40
    asolntsev labeled #1583
  • 15:40
    asolntsev assigned #1583
  • 15:40
    asolntsev opened #1583
  • 15:39

    asolntsev on fix-dependabot

    #984 use gradle format accepted… (compare)

  • 13:06
    xakrurychle edited #1582
  • 13:05
    xakrurychle edited #1582
  • 13:04
    xakrurychle edited #1582
  • 13:04
    xakrurychle edited #1582
  • 13:02
    xakrurychle opened #1582
  • Sep 26 18:57
    evpl edited #1580
  • Sep 26 17:02
    asolntsev labeled #1581
  • Sep 26 17:01
    asolntsev labeled #1581
  • Sep 26 17:01
    asolntsev assigned #1581
  • Sep 26 17:01
    asolntsev opened #1581
  • Sep 26 16:47
    evpl edited #1580
  • Sep 26 16:46
    evpl edited #1580
  • Sep 26 16:46
    evpl edited #1580
nestekon
@nestekon
Hi Team,
I have a question about dynamic locators as ElementsContainer constructors. Before latest releases I successfully used setSelf(). Now it is not clear how to resolve this structure:
public class Panel1 extends ElementsContainer {
    public Panel2 getPanel2(String title) {
        Panel2 panel2 = new Panel2();
        panel2.setSelf(getSelf().$x(".//*[text()='" + title + "']"));
        return panel2;
    }
}

public class Panel2 extends ElementsContainer {

}
Andrei Solntsev
@asolntsev
@nestekon Wow. I never understand why method setSelf is needed. And still don’t understand.
Classes extending EementsContainer (like Panel2) were not intended to instantiate manually. Instead, you should use method Page2 page = Selenide.page(Page2.class);.
You probably need something like this:
class Panel1 extends ElementsContainer {
  @FindBy(xpath = ".//*[text()='" + title + "']")
  Panel2 panel2;
}

class Panel2 extends ElementsContainer {
}
Or even better, don’t extend ElementsContainer at all. Especially if you don’t use @FindBy fields.
Just create plain old good java objects. Something like
class Panel1 {
  private final SelenideElement root = $(“.body”);
  private final Panel2 panel2 = new Panel2(root, ".//*[text()='" + title + "’]");
}

class Panel2 {
}
nestekon
@nestekon
@asolntsev Thanks for respond!
These examples seems static. The second example looks more suitable. Actually it is similar to my example where root is self, and in this way I will need some abstract class that will keep root.
Andrei Solntsev
@asolntsev
I don’t think you even need this abstract class. Why?
Let every class holds its own data.
nestekon
@nestekon
@asolntsev Every class that represent some container for elements will have root element and setter and getter for it. So it is better to keep this in some abstract class. And ElementsContainer was a good candidate for this. In anyway I want to know how it is intended to resolve the task of page.getPanel1().getPanel2(title); where title is not a constant, but is a test data.
Andrei Solntsev
@asolntsev
@nestekon can we discuss the design together tehing to find a better solution?
First If all, what If i ssy that getters/setters are not needed? You can remove them.
Andrei Solntsev
@asolntsev

Released Selenide 5.18.1: "Localhost is a delicate thing!”

https://selenide.org/2021/02/11/selenide-5.18.1/

nestekon
@nestekon
@asolntsev That's will be fine. And how will we init field of ElementsContainer type based on dynamic xpath?
In this case private final Panel2 panel2 = new Panel2(root, ".//*[text()='" + title + "’]") title can be only constant.
Andrei Solntsev
@asolntsev
It doesn't need to be a field. Create a method 'getPanel2()` instead.
nestekon
@nestekon
@asolntsev Yes. That's right. And to init Panel2we will need root element from parent container and setter or constructor to assign root element of Panel2
Nikolay Voronenko
@spluft_gitlab
Hi, everyone
Could you tell me how does element.shouldBe(enabled) work? I thought that it should check enabled/disabled attribute, but element hasn't it and this sample of code working good. I just want to understand that.
element:<div _ngcontent-spq-c121 class="steps-menu__item steps-menu__item_active ng-star-inserted">Text</div>
Also element could looks like:
<div _ngcontent-spq-c121 class="steps-menu__item ng-star-inserted">Text</div>
Andrei Solntsev
@asolntsev
@nestekon yes, pass root to Panel2 constructor. Simple, stable, readable. No magic, no annotations. Just works.
@spluft_gitlab what is the question? enabled means the absence of disabled attribute. You can just look into source code. It's an open-source project.
nestekon
@nestekon
@asolntsev Totally agree with that. So in our project we've decided to keep everything in this way. And for containers we've used Selenide's ElementsContainer as the super class. But now it turns out that this class is intended to be used only with annotation approach.
Andrei Solntsev
@asolntsev
Basically you can use ElementsContainer for any purpose, but I don't see a big point in it. Probably I am just missing something...
nestekon
@nestekon
@asolntsev Yes, that's not a big point in it. Just because in one of the latest releases setSelf()was deleted I wondered what are the alternative ways to init ElementsContainer
Madhu Palagani
@MadhuPalagani_twitter
I am facing issue... if i assign Configuration.browserSize in only one test case and running tests through testng xml, selenide considering the browsersize value for other test cases also(might be if test run in same thread) ... Note - Using version 5.18.1
Madhu Palagani
@MadhuPalagani_twitter
i am running test cases on selenium grid
Andrei Solntsev
@asolntsev
@MadhuPalagani_twitter Yes, it’s because Selenide opens the browser only once and reuses it between tests.
If you really need to set browser size only in one test, you can just close the browser before and after this test.
But I recommend to always set browserSize to some value. Otherwise your browser size will depend on the screen size of current machine, which can make your tests flaky.
Madhu Palagani
@MadhuPalagani_twitter
@asolntsev Thank you, But i can see the same issue even i close the browser (closeWebDriver()) in testng beforemethod() and aftermethod()
Andrei Solntsev
@asolntsev
@MadhuPalagani_twitter of cause! Because Configuration.browserSize is STATIC. Once set, it stays forever.
Andrei Solntsev
@asolntsev

Released Selenide 5.19.0: "Independence day!"

https://selenide.org/2021/02/24/selenide-5.19.0/

Andrey Kolesnyk
@trugaaa
@asolntsev Hi, I am trying to make logging while browser init, but have faced a problem that no browser is attached to Thread while open() method is not invoked
For logs i use this construction: Log.log.info("Web driver initialisation with configuration:\n${(WebDriverRunner.getWebDriver() as RemoteWebDriver).capabilities}")
if i use it after open method it works fine but if not i get exception
is there a way to use logging while configuring stage?
image.png
My configuring class looks this way
Andrei Solntsev
@asolntsev
Sure, just use method if (WebDriverRunner.hasWebDriverStarted()) {…}
Andrey Kolesnyk
@trugaaa
@asolntsev As I understand, it will help me with exception, but i won't see logs because before open() invoke there is no driver started
(
Andrei Solntsev
@asolntsev
@trugaaa Yes, of course. How do you want to log browser properties when browser is not opened yet?
Andrey Kolesnyk
@trugaaa
maybe there is a way to init browser before open() method?
if there is a way to do this, as i understand it will make tests not to be multithread in future?
Andrey Kolesnyk
@trugaaa
or as I understand, I configure some global settings in Configuration class, mb I can somehow log this, or other Selenide Config class?
Andrei Solntsev
@asolntsev
Yes, it's probably possible, but don't you want to simplify things?
You can just enable webdriver logs. Webdriver already writes all its properties out if the box.
Andrey Kolesnyk
@trugaaa
Hello, i have a question) is it possible to implement crossbrowser testing with selenide(1 thread - chrome. 2 thread - firefox) via testng
as I understand Selenide Configuration.browser static property dont accept to do it via this property as it is static and is used for all threads
is there a way to do this in such way?
Andrei Solntsev
@asolntsev
Hi.
I typically recommend to create separate tasks (in gradle) or profiles (in Maven) for different browsers. This way you can run cross-browser tests either in parallel or sequentially; you can have separate Jenkins jobs for different browsers; it's easier to track their statuses etc.
Andrei Solntsev
@asolntsev
Andrey Kolesnyk
@trugaaa
@asolntsev thanks for answer) i will do this way, but for my understanding it is not possible to impl crossbrowser testing in one task via selenide because it runs with static Configuration