pdf - Opening new tabs in Chrome using Watir causes problems using open tabs -


short version: new tabs in chrome prevent old tabs being used, fixing means opened tabs pdfs in them reused before human can examine pdfs.

long version: worked this:

  1. open new chrome window main page of app (tab #1) 2.[do process , then] click button , new tab (tab #2) opens pdf in it.
  2. go tab #1 [do process b , then] click button , new tab (tab #3) opens pdf b in it.
  3. go tab #1 [do process c , then] click button , new tab (tab #4) opens , word document c document gets downloaded.
  4. go tab #1 [do process d , then] click button , new tab (tab #5) opens , word document d document gets downloaded.

all tabs stay open , pdfs can viewed. not perfect, workable.

but things changed. pulled used stuff out, put them in methods in file of various tests use them, seemed idea. seems have caused problems losing focus on original window. (i may wrong) i'm stuck with:

  1. open new chrome window main page of app (tab #1)
  2. [do process , then] click button , new tab (tab #2) opens pdf in it.
  3. stay in tab #2 [do process b , then] click button , new tab (tab #3) opens pdf b in it. pdf lost
  4. stay in tab #3 [do process c , then] click button , new tab (tab #4) opens , word document c document gets downloaded. pdf b lost
  5. stay in tab #4 [do process d , then] click button , new tab (tab #5) opens , word document d document gets downloaded.

this caused using "b.windows.last.use" tried using "b.windows.first.use" fails, because focus isn't going tab #1, , watir can't find object in modal needs click. (in `assert_ok': element not clickable @ point (737.5, -373) (selenium::webdriver::error::unknownerror))

so far can tell, fine if 1 of following

  1. get pdfs download. cannot. this page seemed promising, code didn't work , couldn't fix it.
  2. get watir go first page, "for realsies", , find buttons needs
  3. perhaps open new tab every section of test (i'm going one, i'm not overly hopeful)

any ideas? updated watir , ruby both within last 2 months. i'm using chrome on osx. moving windows or ie not viable options.

here section of code. no, i'm not programmer first , foremost.

thanks.

currenturl = "stackoverflow.placeholder.com/works"      # print inventory report .pdf (document 1) b.goto currenturl b.div(:id, 'page').a(:text, 'inventory report').click  sleep 1 b.div(:id, 'printinventoryreportmodal').a(:text, 'a4').click b.link(:id => "submitbtnprint-inventory-report").fire_event "onclick"  # print general list .pdf (document 2) b.goto [main page url] b.div(:id, 'page').a(:text, 'general list').click  sleep 1 b.div(:id, 'printgeneralinventorylistmodal').a(:text, 'a4').click b.link(:id => "submitbtnprint-general-list").fire_event "onclick"  # print general list .doc (document 3) b.goto [main page url]     b.div(:id, 'page').a(:text, 'general list').click  sleep 1 b.div(:id, 'printgeneralinventorylistmodal').a(:text, '.doc').click b.div(:id, 'printgeneralinventorylistmodal').a(:text, 'a4').click b.link(:id => "submitbtnprint-general-list").fire_event "onclick" 

it seems browser.window function not working way expect, or not using properly. since question contains little in terms of examples of how trying change windows (tabs) it's difficult tell might doing wrong.

to start use irb exploring , troubleshooting

get irb, use

require 'watir-webdriver' b = watir::browser.new :chrome 

now manually navigate browser window opens , state have multiple tabs open

now try in irb see if can spit out window titles

b.windows.each {|window| puts window.title} 

if titles different, should able use set window want use. if not different need @ other attributes see if there easy way identify window want. (or maybe use :index)


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -