Issue
I'm creating a test automation framework in C# .Net using Appium to automate IOS and Android and wanted to use Page Object Design Pattern. So I wanted to utilize the PageFactory extension.
By adding the DotNetSeleniumExtras.PageObjects.Core as NuGet package results in an error (red squiggly lines). 4 errors
CS7069: Reference to type 'IFindsById" claims it is defined in 'WebDriver', but it could not be found.
I needed this extension DotNetSeleniumExtras.PageObjects.Core in order for me to instantiate the Page objects and be able to implement the Page Object Design pattern.
Please let me know if I'm missing something here or if there are any workarounds. Thanks in advance!
Below is my code for added context:
using NUnit.Framework;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Appium.PageObjects;
using SeleniumExtras.PageObjects;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
namespace NativeApp_TestAutomation.Tests.Specs.IOS
{
[TestFixture]
public class LoginTest
{
private IOSDriver<IOSElement> _driver;
private HomeScreen _pageObject;
[OneTimeSetUp]
public void BeforeAll()
{
var capabilities = Capabilities.GetIOSCapabilities("");
var serverUri = Env.ServerIsRemote() ? AppiumServer.RemoteServerUri : AppiumServer.LocalServiceUri;
_driver = new IOSDriver<IOSElement>(serverUri, capabilities, Env.LaunchTimeoutSeconds);
var timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0));
_pageObject = new HomeScreen(_driver);
PageFactory.InitElements(_driver, _pageObject, new AppiumPageObjectMemberDecorator(timeSpan));
}
}
}
I'm getting the red squiggly lines here with all having the same errors.
Solution
One of the most common reasons for that is a mixture of version and assemblies because of different versions and their compatibility.
If you can try following steps the issues most likely would be solved:
- Appium.net latest come out with dependency on DotNetSeleniumExtras.PageObjects v3.11.0 and WebDriver 3.141.0
- DotNetSeleniumExtras.Core of v3.12.0 (do not use latest, target v3.12.0) come out with dependency on WebDriver 3.12.0
- DotNetSeleniumExtras.PageObjects v3.11.0 rely on WebDriver 3.11.0
- So by adding WebDriver 3.12.0 version conflict should be fixed.
This one is a simplest approach - if previous version have enough features then It's done and you can just wait for updates.
The second option that can help you is a binding redirects. The idea is pretty simple, you need to ensure that app know where your WebDriver and it is of correct version.
One good explanation is here (but believe me this is the last thing you want to do, fixed in one place become broken in another) Adding a bindingRedirect to a .Net Standard library
Answered By - Maksym
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.