Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Skip splash screen to Outlook using ruby #1392

Closed
VladMoc opened this issue Dec 3, 2020 · 1 comment
Closed

Skip splash screen to Outlook using ruby #1392

VladMoc opened this issue Dec 3, 2020 · 1 comment

Comments

@VladMoc
Copy link

VladMoc commented Dec 3, 2020

Hello,

I have been trying to open outlook using winAppDriver and ruby.

For this, I use this code:

def self.setup
   opts =
       {
           url: "http://127.0.0.1:4723/wd/hub",
           desired_capabilities:
               {
                   platformName: "WINDOWS",
                   platform: "WINDOWS",
                   deviceName: "WindowsPC",
                   app: 'C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE'
               },
           appium_lib:
               {
                   wait_timeout: 30,
                   wait_interval: 0.5
               }
       }
   @core = Appium::Core.for(opts)
   @outlookSession = @core.start_driver
   @current_window_handler = @outlookSession.window_handle
   for $attempt in 0..5
     if $attempt < 6
       puts $attempt
       sleep(10 * $attempt)
       @WindowHandles = @outlookSession.window_handles;
       puts  @WindowHandles 
       begin
         @outlookSession.switch_to.window(@WindowHandles[0])
         if @outlookSession.find_elements(:name, "New Email")[0] != nil
           break
         end
       rescue
         RuntimeError
         puts "Runtime error encountered and rescued."
       end
     end
   end

   @outlookSession.manage.window.maximize
   @outlookSession

The code works fine if the app is in the background but fails if the app is closed with the following error:
Selenium::WebDriver::Error::NoSuchWindowError:

From console I get the following logs:
try 0
Windows handeler 0x002409B2
Runtime error encountered and rescued.
try 1
Runtime error encountered and rescued.
try 2
Runtime error encountered and rescued.
try 3
Runtime error encountered and rescued.
try 4
Runtime error encountered and rescued.
try 5
Runtime error encountered and rescued

So it seems that for all the tries except the first one my windows handlers are empty.

I have looked into this issue when I tried to implement this code. #611

Do I do something wrong? Any suggestion or help is appreciated.

@VladMoc
Copy link
Author

VladMoc commented Dec 5, 2020

The issue was fixed by using version WinAppDriver v1.2.1. I just added this extra opts parameter 'ms:waitForAppLaunch': '50' and removed all the code.

@VladMoc VladMoc closed this as completed Dec 5, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant