Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

I have a problem with pop up window and after Upgrade sellenium to 4.0 is not working #1977

Open
MaxMaxMaks opened this issue Feb 23, 2024 · 5 comments

Comments

@MaxMaxMaks
Copy link

I launched the program, and after clicking a button, a new window popped up where I must enter the password and press Enter. I've been working on this for two weeks and don't know how to handle it. Also, after upgrading Selenium to version 4.0, I cannot launch this. Can somebody please help me with this? Make corrections if necessary.

using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Remote;
using System;
using System.Diagnostics;
using System.Threading;
using System.Collections.ObjectModel;
using Microsoft.VisualBasic;
using OpenQA.Selenium;
using System.Runtime.CompilerServices;
using OpenQA.Selenium.Support.UI;
using System.Text.RegularExpressions;

class Program
{
public static void Main(string[] args)
{
// Start WinAppDriver process
//Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app","Root");
options.AddAdditionalCapability("app", @"C:\Program Files (x86)\InsLauncher.exe");
options.AddAdditionalCapability("deviceName", "SERWER");
options.AddAdditionalCapability("appArguments", "N/R");

    WindowsDriver<WindowsElement> driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), options);
        driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);
    
    var podmiot = driver.FindElementByXPath("//Window[@ClassName=\'Window\'][@Name=\'R\']/Custom[@ClassName=\'SelectDatabasesControl\']/Custom[@AutomationId=\'BazaPodmiotu\']/ComboBox[@AutomationId=\'cbxBaza\']");
    podmiot.SendKeys(" B");
    podmiot.SendKeys(Keys.Enter);

     var aktualizujAndRun = driver.FindElementByXPath("//Button[@Name=\'Aktualizuj i uruchom\'][@AutomationId='btnAktualizujIUruchom']");
     aktualizujAndRun.Click();

    Thread.Sleep(5000);

    AppiumOptions upp = null;
    WindowsDriver<WindowsElement> secondDriver = null;
    Console.WriteLine("TUTAJ");
    var listofAllWindow = driver.FindElementsByXPath("//Window");   
    string s="Aktualizacja podmiotu";

    foreach(var w in listofAllWindow)
    {
        Console.WriteLine($"{w.Text}");
         if( w.Displayed && w.Text.Contains("Aktualizuj"))
             {
                var windowHandle = w.GetAttribute("NativeWindowHandle");
                Console.WriteLine($"Window Handle: {windowHandle}");

                var handleInt = (int.Parse(windowHandle)).ToString("x");
                upp = new AppiumOptions();
                upp.AddAdditionalCapability("appTopLevelWindow", handleInt);
                break;                
            }
    }
        if (upp != null){
        secondDriver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), upp);
        secondDriver.Keyboard.SendKeys(Keys.Escape);
        secondDriver.Keyboard.SendKeys("2*2"+ Keys.Enter);
            }
    

    Thread.Sleep(10000);

    //driver.CloseApp();
   driver.Quit();
}
@anunay1
Copy link

anunay1 commented Feb 27, 2024

Winappdriver does not support selenium 4, it will not work.

@MaxMaxMaks
Copy link
Author

What should I do ?

@anunay1
Copy link

anunay1 commented Feb 28, 2024

Downgrade to 3.141.1.

@MaxMaxMaks
Copy link
Author

In the End this resolve my problem with pop up window ?

@anunay1
Copy link

anunay1 commented Feb 28, 2024

Is that a question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants