Creating own Customised MobileElement by extending from MobileElement
up vote
2
down vote
favorite
I am trying to have own customized MobileElement class that i can add more methods.
For example I have a class named SamplePage and it contains below mobile element:
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public MobileElement SettingsButton;
I use it in test case lets say as below:
samplePage.SettingsButton.click();
What I want to have is as below
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public customisedMobileElement SettingsButton;
A test case with IsVisible() method or CopyText() method I have in customisedMobileElement class:
Assert.isTrue(samplePage.SettingsButton.IsVisible(), "not visible");
samplePage.LoginTextInput.CopyText();
Could you please share your ideas about how to do it?
java appium pageobjects page-factory
add a comment |
up vote
2
down vote
favorite
I am trying to have own customized MobileElement class that i can add more methods.
For example I have a class named SamplePage and it contains below mobile element:
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public MobileElement SettingsButton;
I use it in test case lets say as below:
samplePage.SettingsButton.click();
What I want to have is as below
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public customisedMobileElement SettingsButton;
A test case with IsVisible() method or CopyText() method I have in customisedMobileElement class:
Assert.isTrue(samplePage.SettingsButton.IsVisible(), "not visible");
samplePage.LoginTextInput.CopyText();
Could you please share your ideas about how to do it?
java appium pageobjects page-factory
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am trying to have own customized MobileElement class that i can add more methods.
For example I have a class named SamplePage and it contains below mobile element:
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public MobileElement SettingsButton;
I use it in test case lets say as below:
samplePage.SettingsButton.click();
What I want to have is as below
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public customisedMobileElement SettingsButton;
A test case with IsVisible() method or CopyText() method I have in customisedMobileElement class:
Assert.isTrue(samplePage.SettingsButton.IsVisible(), "not visible");
samplePage.LoginTextInput.CopyText();
Could you please share your ideas about how to do it?
java appium pageobjects page-factory
I am trying to have own customized MobileElement class that i can add more methods.
For example I have a class named SamplePage and it contains below mobile element:
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public MobileElement SettingsButton;
I use it in test case lets say as below:
samplePage.SettingsButton.click();
What I want to have is as below
@iOSFindBy(accessibility = "Settings")
@AndroidFindBy(id = "Settings")
public customisedMobileElement SettingsButton;
A test case with IsVisible() method or CopyText() method I have in customisedMobileElement class:
Assert.isTrue(samplePage.SettingsButton.IsVisible(), "not visible");
samplePage.LoginTextInput.CopyText();
Could you please share your ideas about how to do it?
java appium pageobjects page-factory
java appium pageobjects page-factory
edited Nov 9 at 15:14
Bill Hileman
2,0182617
2,0182617
asked Nov 9 at 8:32
Random
112
112
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
First define the page as follow:
public class SettingPage
@AndroidFindBy(accessibility = "Settings")
@iOSFindBy(accessibility = "Settings")
private MobileElement setting;
public SettingPage(AppiumDriver<MobileElement> driver)
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
public boolean isScreenDisplayed()
try
return setting.isDisplayed();
catch (Exception e)
return false;
public void click()
setting.click();
Then you can use this as following:
public class Test()
AppiumDriver<MobileElement> driver;
//define your desiredCapabilities and appium driver
private SettingPage settingPage;
public void displayTest(
settingPage= new SettingPage(driver);
settingPage.isScreenDisplayed();
public void clickTest(
settingPage= new SettingPage(driver);
settingPage.click();
}
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
First define the page as follow:
public class SettingPage
@AndroidFindBy(accessibility = "Settings")
@iOSFindBy(accessibility = "Settings")
private MobileElement setting;
public SettingPage(AppiumDriver<MobileElement> driver)
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
public boolean isScreenDisplayed()
try
return setting.isDisplayed();
catch (Exception e)
return false;
public void click()
setting.click();
Then you can use this as following:
public class Test()
AppiumDriver<MobileElement> driver;
//define your desiredCapabilities and appium driver
private SettingPage settingPage;
public void displayTest(
settingPage= new SettingPage(driver);
settingPage.isScreenDisplayed();
public void clickTest(
settingPage= new SettingPage(driver);
settingPage.click();
}
}
add a comment |
up vote
0
down vote
First define the page as follow:
public class SettingPage
@AndroidFindBy(accessibility = "Settings")
@iOSFindBy(accessibility = "Settings")
private MobileElement setting;
public SettingPage(AppiumDriver<MobileElement> driver)
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
public boolean isScreenDisplayed()
try
return setting.isDisplayed();
catch (Exception e)
return false;
public void click()
setting.click();
Then you can use this as following:
public class Test()
AppiumDriver<MobileElement> driver;
//define your desiredCapabilities and appium driver
private SettingPage settingPage;
public void displayTest(
settingPage= new SettingPage(driver);
settingPage.isScreenDisplayed();
public void clickTest(
settingPage= new SettingPage(driver);
settingPage.click();
}
}
add a comment |
up vote
0
down vote
up vote
0
down vote
First define the page as follow:
public class SettingPage
@AndroidFindBy(accessibility = "Settings")
@iOSFindBy(accessibility = "Settings")
private MobileElement setting;
public SettingPage(AppiumDriver<MobileElement> driver)
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
public boolean isScreenDisplayed()
try
return setting.isDisplayed();
catch (Exception e)
return false;
public void click()
setting.click();
Then you can use this as following:
public class Test()
AppiumDriver<MobileElement> driver;
//define your desiredCapabilities and appium driver
private SettingPage settingPage;
public void displayTest(
settingPage= new SettingPage(driver);
settingPage.isScreenDisplayed();
public void clickTest(
settingPage= new SettingPage(driver);
settingPage.click();
}
}
First define the page as follow:
public class SettingPage
@AndroidFindBy(accessibility = "Settings")
@iOSFindBy(accessibility = "Settings")
private MobileElement setting;
public SettingPage(AppiumDriver<MobileElement> driver)
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
public boolean isScreenDisplayed()
try
return setting.isDisplayed();
catch (Exception e)
return false;
public void click()
setting.click();
Then you can use this as following:
public class Test()
AppiumDriver<MobileElement> driver;
//define your desiredCapabilities and appium driver
private SettingPage settingPage;
public void displayTest(
settingPage= new SettingPage(driver);
settingPage.isScreenDisplayed();
public void clickTest(
settingPage= new SettingPage(driver);
settingPage.click();
}
}
answered Nov 9 at 16:56
Suban Dhyako
547115
547115
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222227%2fcreating-own-customised-mobileelement-by-extending-from-mobileelement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown