-1

Without a modal or alert popup. Pressing a button takes me to a page in such a way that selenium can no longer see the controls.

I have tired do reacquire the page without success.

visit([purchase page])
login
sleep(10)
find(:xpath, './/div[@class="tab-pane active"]/div/div/button[@class="btn btn-primary"]').click

Net::ReadTimeout (Net::ReadTimeout)

What I am fairly certain of is that is not not finding my element because I didn't generate a

ElementNotFound

My question is, what are the tools I want to try to get selenium to see the page I wish to manipulate?

TangibleDream
  • 601
  • 8
  • 29
  • Please provide more information about the action that pulls up the unreadable page as well as what is on the page. In general standard browser functionality should never result in a page you can't read (with the exception of IE sometimes). I'm thinking that the page is being rendered in an unusual manner than a standard browser window. – mutt Mar 21 '17 at 21:45
  • You should never get a Net::ReadTimeout - that would tend to imply that whatever you've done has hung the browser/geckodriver/chromedriver/etc depending on what browser you're using. What exactly does clicking the button do ? Also, using `page.driver.browser.switch_to` is a bad smell, just use the Capybara provided window management methods. – Thomas Walpole Mar 21 '17 at 22:05
  • I'm using Firefox. I select an item to purchase. A preview modal appears. I approve the item for purchase. Then the purchase page loads, which I cannot access. – TangibleDream Mar 21 '17 at 22:14
  • 1
    Does the purchase page load in an iframe? Can you share the html? – Mark Lapierre Mar 21 '17 at 22:47
  • Most payment pages contain an iframe that contains the section of the payment page where the credit card or other payment information goes. Do some googling on "ruby selenium iframe" and you'll find some solutions you can try. – JeffC Mar 22 '17 at 03:08
  • @TangibleDream When you say the "purchase page loads", does it load in the current tab? does it open a new tab? It's unclear from your description why you're attempting to switch to multiple windows (and by doing that using driver specific methods Capybara can't track what you're doing, so it is very likely to cause consistency errors). Maybe adding the full test code for what you're trying to do would provide us with more info. – Thomas Walpole Mar 22 '17 at 18:04
  • @ThomasWalpole I have isolated this by going to the purchase page directly from login. An aspnetform loads an empty box, then a call goes to the database, this returns the items for purchase. I updated my script/question for simplicity removing the switch.to.window commands. – TangibleDream Mar 23 '17 at 20:56
  • @JeffC no iframe, an aspnetform though – TangibleDream Mar 23 '17 at 21:12
  • @TangibleDream What is the stacktrace on the error, is the error being raised in the find or click method? What does the browser show when this is happening? What version of selenium and browser are you using? It should never return a Net::ReadTimeout unless the browser or geckodriver is crashing for some reason, or potentially if you are doing an `execute_script` that is opening a system modal. – Thomas Walpole Mar 23 '17 at 22:09
  • @ThomasWalpole it's happening at the find, I'm just running what I pasted, all the monkey business is happening behind the scenes on the page itself. I'd love to find an abstract like before. – TangibleDream Mar 24 '17 at 13:40
  • @ThomasWalpole ```And I open the shopping thingy # features/step_d efinitions/test_1_sd.rb:1 Net::ReadTimeout (Net::ReadTimeout) ./features/step_definitions/test_1_sd.rb:6:in `/^I ope n the shopping thingy$/' features/tools/Tool06_direct_access_to_shopping_thingy.feature:5:in `And I o pen the shopping thingy'``` – TangibleDream Mar 24 '17 at 13:43
  • So I found this dated entry about aspnetform http://stackoverflow.com/questions/4336867/asp-net-form-the-form-name-id-changes-to-aspnetform – TangibleDream Mar 24 '17 at 13:57
  • @TangibleDream thats the cucumber error summary which shows which step the error occurred in, further back in the log I would hope there is an actual stacktrace that shows where the error was actually raised in the gem code. Also you can output `page.html` to see what is actually on the page. – Thomas Walpole Mar 24 '17 at 16:43

1 Answers1

0

One way I would debug this is by putting save_and_open_page before and after xpath. My guess is that it can't find the xpath to click on and its timing out.

page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
save_and_open_page 
find(:xpath, './/div[@class="blah active"]/div/div/button[@class="btn btn-primary"]').click
save_and_open_page 

If this is not the case you can try and set the timeout to 90 seconds to see if it helps.

# https://github.com/teamcapybara/capybara/issues/1305
Capybara.register_driver :selenium do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 90 # instead of the default 60
  Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile, http_client: client)
end

Based off your Firefox error

  1. visit https://ftp.mozilla.org/pub/utilities/profilemanager/1.0/.
  2. download profilemanager.mac.dmg
  3. open up profile manager
  4. select default or create a new profile manager
  5. click on start firefox
  6. Error should be fixed now
David Gross
  • 1,863
  • 10
  • 14
  • after adding the lauchy gem, it comes back with ```Your Firefox profile cannot be loaded. It may be missing or inaccessible.``` I still timeout. What if I try to visit the page I'm trying access? – TangibleDream Mar 22 '17 at 15:18
  • Hey @TangibleDream I just updated the answer with what I think would fix that error. You might get another error but it should run now. – David Gross Mar 22 '17 at 15:47