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

Can not set io.appium.java_client.MobileElement field #919

Closed
vikramvi opened this issue Sep 4, 2017 · 16 comments
Closed

Can not set io.appium.java_client.MobileElement field #919

vikramvi opened this issue Sep 4, 2017 · 16 comments

Comments

@vikramvi
Copy link
Member

vikramvi commented Sep 4, 2017

I'm trying to use sing page object for Android & iOS, one of the elements looks as below

@AndroidFindBy(xpath="//android.widget.Button[@text='Log In']")
     @iOSFindBy(xpath="//XCUIElementTypeButton[@label='Log In']")
     MobileElement WPLogInButton;

This is throwing error as below

net.thucydides.core.pages.WrongPageError: The page object class com.serenity.appium.poc.FlipkartLoginPage looks dodgy:
Failed to instantiate page (java.lang.IllegalArgumentException: Can not set io.appium.java_client.MobileElement field com.serenity.appium.poc.FlipkartLoginPage.WPLogInButton to com.sun.proxy.$Proxy17)

	at net.thucydides.core.pages.Pages.thisPageObjectLooksDodgy(Pages.java:267)
	at net.thucydides.core.pages.Pages.getCurrentPageOfType(Pages.java:222)
	at net.thucydides.core.pages.Pages.getPage(Pages.java:89)
	at net.thucydides.core.steps.PageObjectDependencyInjector.instantiatePageObjectIfNotAssigned(PageObjectDependencyInjector.java:54)
	at net.thucydides.core.steps.PageObjectDependencyInjector.injectDependenciesInto(PageObjectDependencyInjector.java:32)
	at net.thucydides.core.steps.StepFactory.injectOtherDependenciesInto(StepFactory.java:142)
	at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:132)
	at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:118)
	at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:83)
	at net.thucydides.core.steps.StepFactory.getStepLibraryFor(StepFactory.java:77)
	at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:52)
	at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:41)
	at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:23)
	at net.serenitybdd.junit.runners.SerenityRunner.injectScenarioStepsInto(SerenityRunner.java:531)
	at net.serenitybdd.junit.runners.SerenityRunner.methodInvoker(SerenityRunner.java:495)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:273)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:429)
	at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:52)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:241)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

As per my understanding this should work with fixes related to latest appium java client

@wakaleo
Copy link
Member

wakaleo commented Sep 4, 2017

You will need to debug the code to see what it is doing and why it is failing to instantiate.

@livastar
Copy link

livastar commented Sep 5, 2017

@vikramvi related to this: #661

@vikramvi
Copy link
Member Author

vikramvi commented Sep 6, 2017

@livastar Per my understanding 93a719f#diff-503f218d646c10f484fdc9d6315bf2e3, should have fixed this problem & #661.

Please correct if I'm wrong cc: @wakaleo

@livastar
Copy link

livastar commented Sep 6, 2017

@vikramvi
As I understand this issue is not related to the java-client. It's all about serenity.

you can use this:
@AndroidFindBy(xpath="//android.widget.Button[@text='Log In']")
@iOSFindBy(xpath="//XCUIElementTypeButton[@Label='Log In']")
WebElement (or WebElementFacade) WPLogInButton;

@vikramvi
Copy link
Member Author

vikramvi commented Sep 6, 2017

@livastar I've observed one more strange issue, the working code https://github.com/vikramvi/AppiumSerenityPOC broke when I used latest version of framework 1.5.9, any idea what may be going wrong ?

@vikramvi
Copy link
Member Author

vikramvi commented Sep 7, 2017

@livastar can you please update your project https://github.com/livastar/myTestFrameWork with latest serenity release to see this issue ?

@vikramvi
Copy link
Member Author

@livastar can you please try your project with latest version of serenity-core and let me know if it works ?

@livastar
Copy link

Right now I cannot upgrade to the latest version of serenity or even java-client
I'm using 1.5.0-rc.1 and 5.0.0-BETA8

@samsonbarukula
Copy link

when I tried this I am getting error : public class iOSPageObjectTest {

private WebDriver driver;
private TestAppScreenSimple uiTestApp;

@Before
public void setUp() throws Exception {
	DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("deviceName", "Mathews P Abraham’s iPad");
    desiredCapabilities.setCapability("automationName", "XCUITest");
    desiredCapabilities.setCapability("platformName", "iOS");
    desiredCapabilities.setCapability("platformVersion", "11.0");
    desiredCapabilities.setCapability("app", "/Users/john/Desktop/ThirdChanl/DarshanGiven/ThirdChannel-ios.app");
    desiredCapabilities.setCapability("udid", "c7a326449ae89e2eeabdace74ec304f56462643e");

    URL remoteUrl = new URL("http://localhost:4723/wd/hub");

//
// File appDir = new File(System.getProperty("user.dir"),
// "../../../apps/TestApp/build/release-iphonesimulator");
// File app = new File(appDir, "TestApp.app");
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
// - capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
// - capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
// + capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.3");
// + capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6");
// capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
//
uiTestApp = new TestAppScreenSimple();
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), desiredCapabilities);

	PageFactory.initElements(new AppiumFieldDecorator(driver), uiTestApp);
	System.out.println("dfdsfasdfa");
}

@samsonbarukula
Copy link

error for the above : Nov 17, 2017 7:33:59 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

@samsonbarukula
Copy link

any help pls urgent

@wakaleo
Copy link
Member

wakaleo commented Nov 17, 2017

Hi @samsonbarukula, as this is an open source project, there is no SLA on defect fixes. If you do need urgent help, we would be happy to look into your issue as part of a commercial support agreement. Some of our support models can be found here: https://johnfergusonsmart.com/serenity-bdd-mentoring/

@samsonbarukula
Copy link

thank you let me go through

@samsonbarukula
Copy link

I would like to know whether it is possible for iOS 10 and above on real devices ?

@jeevan1987cool
Copy link

@wakaleo any update on this? This is still reproducible for me.

<serenity.version>2.0.81</serenity.version>
<serenity.cucumber.version>1.9.45</serenity.cucumber.version>

@jeevan1987cool
Copy link

I have uploaded the repo here https://github.com/jeevan1987cool/SampleSerenityIOSbdd/tree/master/test-optinOne to reproduce the issue.

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants