Creating own Customised MobileElement by extending from MobileElement
up vote
1
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
1
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
1
down vote
favorite
up vote
1
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 15 hours ago
Bill Hileman
2,0032617
2,0032617
asked 22 hours ago
Random
62
62
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 13 hours ago
Suban Dhyako
45612
45612
add a comment |
add a comment |
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
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
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
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
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