【问题标题】:Appium : how to test webappication in chrome on windows 10?Appium:如何在 Windows 10 上的 chrome 中测试 Web 应用程序?
【发布时间】:2023-03-24 18:05:01
【问题描述】:

我正在尝试使用 Appium 对在 Windows 10 上以 chrome 运行的 Web 应用程序进行自动化测试。 我有如下代码,使用 chromedriver 可以很好地工作。我想将此移至基于 appium 的方法。

RemoteWebDriver driver = new ChromeDriver(@"C:\Users\Administrator\Downloads\chromedriver_win32");
            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));

driver.Url = "https://www.bing.com/";
RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(x => x.Title.Contains("webdriver"));

我在互联网上搜索并找到了很多代码来在 Windows 设备上的 android 模拟器上测试 chrome 上的 web 应用程序。我没有找到任何直接在 Windows 10 上运行 chrome 浏览器的示例。 根据我的理解,我尝试通过更改所需功能来采用代码,如下所示。

DesiredCapabilities caps = DesiredCapabilities.Chrome();
caps.SetCapability(CapabilityType.BrowserName, "chrome");
caps.SetCapability(CapabilityType.Version, "60");
caps.SetCapability(CapabilityType.Platform, "Windows 10");
caps.SetCapability("platformName", "Windows");
//caps.SetCapability("app", @"C:\Users\Administrator\Downloads\chromedriver_win32\Chromedriver.exe");
caps.SetCapability("app", @"Chrome");
caps.SetCapability("deviceName", "WindowsPC");

driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4725/wd/hub"), caps, TimeSpan.FromSeconds(60));
driver.Url = "https://www.bing.com/";
((IWebDriver)driver).Navigate().GoToUrl("https://www.bing.com/");
RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);

Thread.Sleep(5000);
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(x => x.Title.Contains("webdriver"));

但这不起作用。 我认为问题在于我无法弄清楚如何设置所需的功能,以便在http://127.0.0.1:4725/wd/hub 上运行的 appium 服务能够启动 chromedriver 并运行测试。

有人可以帮忙指出上述代码的错误吗? 感谢您的帮助。

【问题讨论】:

    标签: c# windows automated-tests appium


    【解决方案1】:

    你需要传递安卓手机的功能,而不是你传递的windwos pc

    caps.SetCapability("platformName", "Windows");
    

    这样,如果你正在使用它,你需要通过模拟器或安卓手机的操作系统版本..

    作为参考访问这个网站你会知道你需要知道的一切..

    http://www.automationtestinghub.com/launch-chrome-browser-on-mobile-device/

    很高兴为您提供帮助。如果该解决方案适合您,请告诉我们

    【讨论】:

    • 澄清一下,我正在尝试在 Windows 10 上而不是在 android 上运行测试。谢谢。
    • 但你说你需要在模拟器上运行测试
    • 对不起,如果我不清楚,这就是问题所在。我正在尝试在 chrome 浏览器中在 windows 10 上运行测试。接下来,我将尝试在 wpf 应用程序中通过 chrome embedded(CEF) 测试相同的 Web 应用程序
    【解决方案2】:

    很好地放在这里 - https://crossbrowsertesting.com/blog/appium/appium-native-web-hybrid-applications/

    Appium 是一个开源测试自动化框架,它使用 WebDriver 协议(又名 Selenium API)驱动 iOS 和 Android 原生、移动和混合应用。也就是说,Appium 就像 Selenium 的表亲,用于测试移动应用程序而不是桌面浏览器中的 Web 应用程序

    根据此处的讨论 - https://discuss.appium.io/t/can-appium-automate-desktop-web-browsers/746/5 也似乎 appium 仅用于在移动设备上进行测试。

    【讨论】:

      猜你喜欢
      • 2014-12-03
      • 2018-10-13
      • 2016-04-16
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 2018-06-04
      • 2019-01-21
      • 1970-01-01
      相关资源
      最近更新 更多