1

I'm trying to do functional testing using Selenium Webdriver.

I'm using ruby code to test on multiple windows at the same time using multi-threading

The problem is when the thread creates the new window, the other window will lose focus and the send keys process from that window fill stop and the test fails.

How can I handle this window focus issue?

Thanks

Note : every browser window has its own driver instance

Update :

here How I create the thread

begin
    while testIndex < testCases.length #  End when every testcase has been tested
        if(Thread.list.count<threadLimit+1) # if thread slot available 
            th[testIndex] = Thread.new(testIndex){ |i| # Create Thread
                # get testCase input
                # initiate driver and run test
                # I have wraper for this, and there is no thread inside it, just single thread code
            }
        end
    end

    th.each{|t| 
        if(!t.nil?)
            t.join # Wait unfinished thread
        end
    }
rescue Exception => e
    puts "MESSAGE: #{e}"
end

Update II

Trying investigate the issue again based on @Leon comment. and it's work, but just in Chrome it's fail in IE, FF, dan Phantom

The errors such as :

  • CSRF token error (IE) - already using cleanSession and private, work on single thread test so it's not the web code error, this make selenium fail to find element which caused the script stoped,
  • Unable to bind to locking port 7054 (Firefox),
  • Unable to bind to locking port 8909 (Phantom)

Update III

Updated my selenium to 3.4 , the errors is gone. But the weird things is only phantomjs don't execute it concurently.

  • Updates title to be about multiple windows. It said browsers which made me think of firefox, chrome, Safari, etc. – Michael Durrant Jul 21 '17 at 10:58
  • Are you using capybara ? – Michael Durrant Jul 21 '17 at 11:16
  • nice icon also btw – Michael Durrant Jul 21 '17 at 11:17
  • @Michael I'm using plain selenium webdriver – Sunu Pinasthika Fajar Jul 21 '17 at 13:51
  • 1
    What you used exactly to initiate multi-threading,what your relevant code looks like? I use java for my tests and by making tasks that include the testing code I want (on their own driver instance) and feeding them to a multiple thread executor work just fine. If every browser window has its own driver instance, what you described shouldnt happen, being on focus isnt a requirement to run selenium be it single-threaded or multi-threaded. You should be able to have the windows in background and they should work just fine. – Leon Jul 21 '17 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.