#selenium

/

      • LocusAsaf
        it just becomes the root of the new page
      • I suppose I could re-return the driver though
      • davehunt has quit
      • its a little bit strange though
      • titusfortner joined the channel
      • yenaemj_ has quit
      • anyone else want to offer advice here
      • marmotworks: you seemd to have some idea?
      • D3M0S
        I'm not sure I really grasp what's going on, if you want to pastebin some more code or do a gist I might be able to help more
      • also, not much of a python guy
      • so yeah
      • LocusAsaf
        okay I'll do a pastebin
      • sgsabbage has quit
      • jimevans1 joined the channel
      • this is basically what I was saying
      • the confusing part is anything after line 9, since I'm on page y instead of page x
      • D3M0S
        have you heard of Page Object Pattern??
      • LocusAsaf
        the thing to mention is that the test function automatically does that is in the fixture code automatically based on the argument in the test
      • D3M0S
        this might be your missing peice here
      • LocusAsaf
        I think I do but please humor me
      • octomeow
        def needs a page object
      • LocusAsaf
        go on please
      • octomeow
        umm how do I explain that...
      • D3M0S
        so create objects to represent your page
      • jimevans has quit
      • octomeow
        I have a driver defined once and for all, basepage class to sum up all the interactions, and lots of children classes for each page
      • D3M0S
        let me type out a paste, and hopefully pseudo pythonize you're stuff to give you a good idea
      • octomeow
        basepage class has a method which inits the page of needed type
      • so any method defined in any page can return any other page type
      • LocusAsaf
        octomeow: what I think you're all talking about is a class that has all the appropriate css and helper methods to do something on a page
      • D3M0S
        man, I can't write python, would you be able to understand it if I did it in Java?
      • octomeow
        to make this possible: page = ((BasePage)page).OpenSignInForm().ValidLogin(PRSettings.Username, PRSettings.Password1);
      • LocusAsaf
        D3M0S: yes
      • octomeow: you're talking about java too right
      • octomeow
        C#
      • chris_____ has quit
      • LocusAsaf
        oh yikes
      • octomeow
        sorry going to lunch
      • LocusAsaf
        okay thanks
      • octomeow
        can probably pastebin some code after
      • LocusAsaf
        D3M0S: let me know when you have an example
      • D3M0S
        LocusAsaf, will do, just working on it now
      • smyers
        Things I've learned writing tests with pytest and selenium: Page objects are good. Providing a function that gives you a webdriver instance is good, so you don't need the test framework to get a browser.
      • kggr joined the channel
      • Baking navigation into fixtures is no fun, because it makes interactive development much harder, versus just having a navigate('destination') function.
      • LocusAsaf
        smyers: so you would favor just having the same boilerplate in every single function?
      • smyers
        Dear god no
      • LocusAsaf
        like "login(driver); navigate('destination', driver);"
      • if you don't let the fixture do it then what will do it?
      • you need to call those two functions somewhere
      • smyers
        And, ideally, that place would be your page object: login_page_instance.login(username, password)
      • In the test, that would be followed by an assertion
      • Outside of the test, you'd have a webdriver instance that you can poke at for prototyping tests
      • LocusAsaf
        smyers: I don't really see the benefit of creating a page object other than storing some css
      • where instead I can just have a login function which is much leaner and easier to understand than a page object
      • although you're all trying to convince me now I'm just kind of visual so I'm probably not seeing the full picture you're trying to describe
      • NOTICE: Yippee, build fixed!
      • NOTICE: Project Firefox 31 XP Synthesized Java Tests build #1209: FIXED in 11 min: http://ci.seleniumhq.org:8080/job/Firefox%2031%20XP%20Synthesized%20Java%20Tests/1209/
      • smyers
        I expect you will come to see the benefit in time, unless the thing you're testing never changes and isn't in any way complex.
      • LocusAsaf
        smyers: if I single login method it's as simple as changing some content in that method, whats the difference if its a method or a class?
      • smyers
        That's sorta like asking about the benefits of object-oriented programming, no?
      • LocusAsaf
        functions are as object-oriented as classes are
      • how is a function not object oriented
      • sircapsalot
        what's object-oriented programming?
      • D3M0S
      • sircapsalot kidding..
      • smyers backs away slowly
      • LocusAsaf
        I'm not trying to be snarky, forget what I said
      • let me create an example and you tell me what's better
      • D3M0S
        LocusAsaf, did you see my example for your situation using Page Objects in java
      • LocusAsaf
        will look in just one second
      • D3M0S
        there's ofc better ways than just passing the driver around in constructors
      • but I'll leave those up to you.
      • admc has quit
      • santiycr
        lukeis: let's do eet
      • I'm out next week, but I'll send you an email so we can start planning
      • lukeis
        sounds good :)
      • LocusAsaf
      • is that a good example, am I missing anything, do you see anything better about the object vs. the function?
      • D3M0S: looking now
      • D3M0S: okay so your trick is that you have well defined routes from one page (or object) to another and you return the next page that contains the same driver
      • D3M0S
        not my trick, this is page object pattern
      • LocusAsaf
        fair enough but what i said is true
      • D3M0S
        yep
      • as you can see, the advantages are in maintainability and readability in the actual test
      • LocusAsaf
        this is what I was kind of mentioning before too
      • D3M0S
        which are like..the 2 most important things
      • LocusAsaf
        it definitely makes a lot more sense in java I'm not totally sold on doing page objects in python though
      • I'm curious what smyers has to say though
      • or anyone else that is familiar with python and wants to look at my bpaste
      • pastebin rather
      • smyers
        This really is a discussion of the merits of OO design, which are intrisic to the value of the page object model.
      • (even in python)
      • LocusAsaf
        smyers: I totally agree and I'm totally fine if you say that I'm wrong
      • was my example sound though?
      • D3M0S
        yeah, page object model is shite with terrible OOD
      • kggr has quit
      • LocusAsaf
        was I missing anything there?
      • merobertsjr__ has quit
      • D3M0S
        and your ability to take OOD principals and design patterns and efficiently put them into effect is really what makes page object model strong or mediocre
      • LocusAsaf
        I just want to know specifically why because I just don't see it right now
      • merobertsjr__ joined the channel
      • smyers
        I can't really answer that for you. All I can do is suggest that you separate your concerns wherever possible because things change, your assumptions will be challenged, and refactors will happen.
      • LocusAsaf
        separate what concerns?
      • D3M0S
        smyers, +1
      • D3M0S sighs
      • don't stick your hand in fire, why?
      • because you'll get burned, whats a burn?
      • smyers
        Again, I can't really answer that for you. Or, in this case, shouldn't. You clearly need to be concerned with how to havigate to a page. Also locating elements is important, right? Filling forms, I assume?
      • LocusAsaf
        yes of course
      • smyers
        My apologies, those were rhetorical questions. I don't know what your concerns are, so I don't know how to separate them.
      • LocusAsaf
        okay well it feels like I'm reading a forunte from a cookie right now
      • let me continue
      • D3M0S
        LocusAsaf, they're pretty common programming principals
      • LocusAsaf
        I can create a file called "login_page.py", "x_page.py" and I can put two different styles of things in there
      • one style would be putting in classes, see the pastebin I example
      • another style would be putting in functions, again see example
      • when page X changes some css, I go into said file, change some constants and I'm done
      • D3M0S
        LocusAsaf, yeah, that's separation of concerns
      • LocusAsaf
        you're telling me follow OO, stuff will change
      • either if I put classes or functions, they are still objects and you can consider both "page objects"
      • so unless you can convince me that my functions should be methods in classes, I'm not going to write extra code
      • if you can convince me that it's good, I'll gladly put the code in
      • D3M0S
        It's not my job to convince you of anything
      • NOTICE: Yippee, build fixed!
      • NOTICE: Project Firefox 31 XP Javascript Tests build #1437: FIXED in 6 min 36 sec: http://ci.seleniumhq.org:8080/job/Firefox%2031%20XP%20Javascript%20Tests/1437/
      • nbnds has quit
      • LocusAsaf, I can only say this, I've been doing this for 5 years, and this is the way I do things...there are plenty other developers out there and in this channel that feel the exact same as I do
      • Follow good design principals, lest there be dragons.
      • LocusAsaf
        D3M0S: absolutely
      • and I agree with you
      • and I apologize
      • I don't mean to be argumentative. I know i'm not perfect and I know there is more to learn, that is why I come here to ask questions. I'm delighted when someone tells me I'm doing it wrong and shows me a better way
      • D3M0S
        and "writing extra code" you saw my simple java example right?
      • in java there's load of "extra code"
      • LocusAsaf
        I think the point I'm trying to make is that my code is just as OO as your example
      • the question I was asking smyers is a bit language specific though
      • as in, there are many ways to skin the cat
      • sometimes one is better, sometimes they are the same
      • I was asking, which way do you think is better and why, or are they the same?
      • D3M0S: what you code did illustrate is that in my page objects I can have well defined routes to another page and have it return the same driver
      • aaronhum_ joined the channel
      • it's a little bit contrived in the way I'm defining my page objects since the driver is not really being mutated
      • but I think it's a reasonable way to solve my problem
      • aaronhum_ has quit
      • aaronhum_ joined the channel
      • smyers
        The biggest reason I can give you is that going with page objects and other reasonable abstractions will save your ass down the line when refactoring is necessary.
      • aaronhumerickhou has quit