Okay it clearly make sense. Thanks. On Wed 8 Aug, 2018, 12:29 AM Titus Fortner, <[email protected]> wrote:
> Whether you use or don't use the block should be independent of whether > you want to close the window. > > b.window(title: /foo/).use do > do_things > end > > is the exact same thing as > > b.window(title: /foo/).use > do_things > b.original_window.use > > I avoid doing things by block whenever possible, and this extra line of > code is more than worth the tradeoff when it comes to debugging problems. > > Note that neither of them will close the window unless `b.window.close` is > explicitly called. > > > > > > On Tuesday, August 7, 2018 at 11:41:47 AM UTC-7, rajagopalan madasami > wrote: >> >> If you block while you are switching to the new window then it has to >> close while we are coming out of the block. >> >> If we don't want close, then we should not be using the block. >> >> Yes? Or is it not a good idea? >> >> On Wed 8 Aug, 2018, 12:09 AM Titus Fortner, <[email protected]> wrote: >> >>> I'm lost on what your question is. >>> >>> >>> >>> >>> On Tuesday, August 7, 2018 at 11:30:00 AM UTC-7, rajagopalan madasami >>> wrote: >>>> >>>> Hi sorry once again, please read this. >>>> >>>> >>>> If I want to switch the window again I should not using block. I need >>>> to use the way you are using without block >>>> >>>> On Tue 7 Aug, 2018, 11:54 PM Titus Fortner, <[email protected]> >>>> wrote: >>>> >>>>> What are you asking? The block should not close the window >>>>> automatically, what if you want to switch to it again? >>>>> >>>>> >>>>> >>>>> On Tuesday, August 7, 2018 at 11:17:45 AM UTC-7, rajagopalan madasami >>>>> wrote: >>>>>> >>>>>> >>Ah, this got lost in the business that is Watir General this week<< >>>>>> >>>>>> I didn't understand this line. >>>>>> >>>>>> I know it switched back but the window which has switched left for no >>>>>> reason ? When it comes to block it obviously has to close the window >>>>>> which >>>>>> has been opened and switched. If you are not using block then there is no >>>>>> need and that's what intented because user wants to take control of when >>>>>> to >>>>>> close but when using the block he is obviously expecting the switched >>>>>> window to be closed when he returns back, otherwise it's opened for what? >>>>>> >>>>>> On Tue 7 Aug, 2018, 11:41 PM Titus Fortner, <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Ah, this got lost in the business that is Watir General this week >>>>>>> >>>>>>> If you are using the block it will automatically switch back to the >>>>>>> original window for you. >>>>>>> I don't like using blocks for things like this, so I explicitly >>>>>>> switch back using `#original_window`. >>>>>>> >>>>>>> Neither approach automatically closes a window, so if it isn't the >>>>>>> side effect of another action, you'll need to do that explicitly. >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Tuesday, August 7, 2018 at 11:00:40 AM UTC-7, rajagopalan >>>>>>> madasami wrote: >>>>>>>> >>>>>>>> Hi here you forgot to reply my previous mail. When I use block when >>>>>>>> switching to the window , it's automatically needs to close the >>>>>>>> window, eh? >>>>>>>> Please see my previous mail as well. >>>>>>>> >>>>>>>> On Tue 7 Aug, 2018, 8:56 PM Titus Fortner, <[email protected]> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Oh no, I gave the right code: >>>>>>>>> https://stackoverflow.com/a/51666596/4072371 >>>>>>>>> >>>>>>>>> Also, original_window is stored for you, you don't need to create >>>>>>>>> it. >>>>>>>>> >>>>>>>>> b.select_list(id: 'selWeek').options.each do |option| >>>>>>>>> option.select >>>>>>>>> b.button(id: 'csbtnSearch').click(:control) >>>>>>>>> b.windows.last.use >>>>>>>>> p b.element(xpath: >>>>>>>>> '//*[@id="form1"]/table/tbody/tr[1]/td[1]/a').text >>>>>>>>> b.window.close >>>>>>>>> b.original_window.use >>>>>>>>> end >>>>>>>>> On Tue, Aug 7, 2018 at 8:20 AM Titus Fortner <[email protected]> >>>>>>>>> wrote: >>>>>>>>> > >>>>>>>>> > Gah, I mixed in Selenium code. >>>>>>>>> > >>>>>>>>> > In Selenium `driver.close` closes the window, and `driver.quit` >>>>>>>>> ends >>>>>>>>> > the session. >>>>>>>>> > In Watir it needs to be `b.window.close` >>>>>>>>> > >>>>>>>>> > Let me find the SO entry to fix it. >>>>>>>>> > On Tue, Aug 7, 2018 at 4:05 AM <[email protected]> wrote: >>>>>>>>> > > >>>>>>>>> > > Hi Titus, >>>>>>>>> > > >>>>>>>>> > > We have recently had the talk in Stackoverflow, where you have >>>>>>>>> suggested me this code >>>>>>>>> > > >>>>>>>>> > > I tried using your code but when I reach b.close, it's closing >>>>>>>>> the browser totally not the tab which has opened recently so I >>>>>>>>> couldn't >>>>>>>>> connect to the original window. >>>>>>>>> > > >>>>>>>>> > > Please execute this code >>>>>>>>> > > >>>>>>>>> > >> require 'watir' >>>>>>>>> > >> driver = Selenium::WebDriver.for :chrome >>>>>>>>> > >> b = Watir::Browser.new driver >>>>>>>>> > >> >>>>>>>>> > >> b.goto ' >>>>>>>>> https://services.wiltshire.gov.uk/PlanningGIS/LLPG/WeeklyList' >>>>>>>>> > >> >>>>>>>>> > >> b.select_list(id: 'selWeek').options.each do |option| >>>>>>>>> > >> option.select >>>>>>>>> > >> b.button(id: 'csbtnSearch').click(:control) >>>>>>>>> > >> original = b.original_window >>>>>>>>> > >> b.windows.last.use >>>>>>>>> > >> p b.element(xpath: >>>>>>>>> '//*[@id="form1"]/table/tbody/tr[1]/td[1]/a').text >>>>>>>>> > >> b.close >>>>>>>>> > >> b.original_window = original >>>>>>>>> > >> end >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > browser b.close is closing the browser not the newly opened >>>>>>>>> tab so I couldn't connect to the original window and this throws the >>>>>>>>> error. >>>>>>>>> Is it a bug? >>>>>>>>> > > >>>>>>>>> > > -- >>>>>>>>> > > -- >>>>>>>>> > > Before posting, please read >>>>>>>>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group >>>>>>>>> . >>>>>>>>> > > In short: search before you ask, be nice. >>>>>>>>> > > >>>>>>>>> > > [email protected] >>>>>>>>> > > http://groups.google.com/group/watir-general >>>>>>>>> > > [email protected] >>>>>>>>> > > --- >>>>>>>>> > > You received this message because you are subscribed to the >>>>>>>>> Google Groups "Watir General" group. >>>>>>>>> > > To unsubscribe from this group and stop receiving emails from >>>>>>>>> it, send an email to [email protected]. >>>>>>>>> > > For more options, visit https://groups.google.com/d/optout. >>>>>>>>> >>>>>>>>> -- >>>>>>>>> -- >>>>>>>>> Before posting, please read >>>>>>>>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. >>>>>>>>> >>>>>>>>> In short: search before you ask, be nice. >>>>>>>>> >>>>>>>>> [email protected] >>>>>>>>> http://groups.google.com/group/watir-general >>>>>>>>> [email protected] >>>>>>>>> --- >>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>> Groups "Watir General" group. >>>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>>> send an email to [email protected]. >>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>> >>>>>>>> -- >>>>>>> -- >>>>>>> Before posting, please read >>>>>>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. >>>>>>> >>>>>>> In short: search before you ask, be nice. >>>>>>> >>>>>>> [email protected] >>>>>>> http://groups.google.com/group/watir-general >>>>>>> [email protected] >>>>>>> --- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Watir General" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to [email protected]. >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> -- >>>>> -- >>>>> Before posting, please read >>>>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. >>>>> >>>>> In short: search before you ask, be nice. >>>>> >>>>> [email protected] >>>>> http://groups.google.com/group/watir-general >>>>> [email protected] >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Watir General" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>> -- >>> Before posting, please read >>> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. >>> >>> In short: search before you ask, be nice. >>> >>> [email protected] >>> http://groups.google.com/group/watir-general >>> [email protected] >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Watir General" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > -- > Before posting, please read > https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. > > In short: search before you ask, be nice. > > [email protected] > http://groups.google.com/group/watir-general > [email protected] > --- > You received this message because you are subscribed to the Google Groups > "Watir General" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
