How to automate a Toast message in Appium without taking screen shot?
up vote
0
down vote
favorite
I want to test a Toast message without taking screen shot. Is there any other way to automate the Toast message?
appium appium-android
|
show 1 more comment
up vote
0
down vote
favorite
I want to test a Toast message without taking screen shot. Is there any other way to automate the Toast message?
appium appium-android
You can get toast message text and verify it as expected
– Ishita Shah
Nov 12 at 11:11
Could u please tell me, how can we achieve that?
– Navya Chinnari
Nov 13 at 7:03
you can refer below example.
– Ishita Shah
Nov 13 at 7:16
How can we get toast message XPATH? (Regarding 1st two lines of code)
– Navya Chinnari
Nov 13 at 7:22
That you have to inspect it anyhow, It is bit complex, But it can inspect.
– Ishita Shah
Nov 13 at 7:24
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to test a Toast message without taking screen shot. Is there any other way to automate the Toast message?
appium appium-android
I want to test a Toast message without taking screen shot. Is there any other way to automate the Toast message?
appium appium-android
appium appium-android
edited Nov 14 at 8:32
greuze
2,31832550
2,31832550
asked Nov 12 at 10:44
Navya Chinnari
112
112
You can get toast message text and verify it as expected
– Ishita Shah
Nov 12 at 11:11
Could u please tell me, how can we achieve that?
– Navya Chinnari
Nov 13 at 7:03
you can refer below example.
– Ishita Shah
Nov 13 at 7:16
How can we get toast message XPATH? (Regarding 1st two lines of code)
– Navya Chinnari
Nov 13 at 7:22
That you have to inspect it anyhow, It is bit complex, But it can inspect.
– Ishita Shah
Nov 13 at 7:24
|
show 1 more comment
You can get toast message text and verify it as expected
– Ishita Shah
Nov 12 at 11:11
Could u please tell me, how can we achieve that?
– Navya Chinnari
Nov 13 at 7:03
you can refer below example.
– Ishita Shah
Nov 13 at 7:16
How can we get toast message XPATH? (Regarding 1st two lines of code)
– Navya Chinnari
Nov 13 at 7:22
That you have to inspect it anyhow, It is bit complex, But it can inspect.
– Ishita Shah
Nov 13 at 7:24
You can get toast message text and verify it as expected
– Ishita Shah
Nov 12 at 11:11
You can get toast message text and verify it as expected
– Ishita Shah
Nov 12 at 11:11
Could u please tell me, how can we achieve that?
– Navya Chinnari
Nov 13 at 7:03
Could u please tell me, how can we achieve that?
– Navya Chinnari
Nov 13 at 7:03
you can refer below example.
– Ishita Shah
Nov 13 at 7:16
you can refer below example.
– Ishita Shah
Nov 13 at 7:16
How can we get toast message XPATH? (Regarding 1st two lines of code)
– Navya Chinnari
Nov 13 at 7:22
How can we get toast message XPATH? (Regarding 1st two lines of code)
– Navya Chinnari
Nov 13 at 7:22
That you have to inspect it anyhow, It is bit complex, But it can inspect.
– Ishita Shah
Nov 13 at 7:24
That you have to inspect it anyhow, It is bit complex, But it can inspect.
– Ishita Shah
Nov 13 at 7:24
|
show 1 more comment
2 Answers
2
active
oldest
votes
up vote
0
down vote
You can get toast message and define Success/Fail operation:
By toastContainer = By.xpath("//div[@id='toast-container']//*");
By toastMessageDA = By.xpath("//div[@class='toast-message']");
public String toastUtility() throws Exception {
toast_container_flag = false;
try {
if (driver.findElement(toastContainer).isEnabled()) {
toast_container_flag = true;
List<WebElement> findData = driver.findElements(toastContainer);
for (WebElement element : findData) {
if (element.getAttribute("class").toString().contains("toast toast")) {
toast_success_fail = element.getAttribute("class").toString();
}
}
validationMessage = "Toast: " + driver.findElement(toastMessageDA).getText();
js.executeScript("arguments[0].click();", driver.findElement(toastMessageDA));
if (toastr_success_fail.equals("toast toast-success")) {
System.out.println("Success Message");
} else if (toastr_success_fail.equals("toast toast-error")) {
System.out.println("Fail Message");
} else {
System.out.println("Other Message");
}
System.out.println(validationMessage);
testResult = validationMessage;
}
} catch (Exception e2) {
testResult = "Toast message is not generated.";
testlog.info(testResult);
System.out.println(testResult);
}
return testResult;
}
add a comment |
up vote
0
down vote
Retrieval of toast messages is already supported for Android. Please look at the below release notes for Android.
https://github.com/appium/appium/releases/tag/v1.6.3
You need to use UIAutomator2 to work with toast messages in Android.
Hope this helps.
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can get toast message and define Success/Fail operation:
By toastContainer = By.xpath("//div[@id='toast-container']//*");
By toastMessageDA = By.xpath("//div[@class='toast-message']");
public String toastUtility() throws Exception {
toast_container_flag = false;
try {
if (driver.findElement(toastContainer).isEnabled()) {
toast_container_flag = true;
List<WebElement> findData = driver.findElements(toastContainer);
for (WebElement element : findData) {
if (element.getAttribute("class").toString().contains("toast toast")) {
toast_success_fail = element.getAttribute("class").toString();
}
}
validationMessage = "Toast: " + driver.findElement(toastMessageDA).getText();
js.executeScript("arguments[0].click();", driver.findElement(toastMessageDA));
if (toastr_success_fail.equals("toast toast-success")) {
System.out.println("Success Message");
} else if (toastr_success_fail.equals("toast toast-error")) {
System.out.println("Fail Message");
} else {
System.out.println("Other Message");
}
System.out.println(validationMessage);
testResult = validationMessage;
}
} catch (Exception e2) {
testResult = "Toast message is not generated.";
testlog.info(testResult);
System.out.println(testResult);
}
return testResult;
}
add a comment |
up vote
0
down vote
You can get toast message and define Success/Fail operation:
By toastContainer = By.xpath("//div[@id='toast-container']//*");
By toastMessageDA = By.xpath("//div[@class='toast-message']");
public String toastUtility() throws Exception {
toast_container_flag = false;
try {
if (driver.findElement(toastContainer).isEnabled()) {
toast_container_flag = true;
List<WebElement> findData = driver.findElements(toastContainer);
for (WebElement element : findData) {
if (element.getAttribute("class").toString().contains("toast toast")) {
toast_success_fail = element.getAttribute("class").toString();
}
}
validationMessage = "Toast: " + driver.findElement(toastMessageDA).getText();
js.executeScript("arguments[0].click();", driver.findElement(toastMessageDA));
if (toastr_success_fail.equals("toast toast-success")) {
System.out.println("Success Message");
} else if (toastr_success_fail.equals("toast toast-error")) {
System.out.println("Fail Message");
} else {
System.out.println("Other Message");
}
System.out.println(validationMessage);
testResult = validationMessage;
}
} catch (Exception e2) {
testResult = "Toast message is not generated.";
testlog.info(testResult);
System.out.println(testResult);
}
return testResult;
}
add a comment |
up vote
0
down vote
up vote
0
down vote
You can get toast message and define Success/Fail operation:
By toastContainer = By.xpath("//div[@id='toast-container']//*");
By toastMessageDA = By.xpath("//div[@class='toast-message']");
public String toastUtility() throws Exception {
toast_container_flag = false;
try {
if (driver.findElement(toastContainer).isEnabled()) {
toast_container_flag = true;
List<WebElement> findData = driver.findElements(toastContainer);
for (WebElement element : findData) {
if (element.getAttribute("class").toString().contains("toast toast")) {
toast_success_fail = element.getAttribute("class").toString();
}
}
validationMessage = "Toast: " + driver.findElement(toastMessageDA).getText();
js.executeScript("arguments[0].click();", driver.findElement(toastMessageDA));
if (toastr_success_fail.equals("toast toast-success")) {
System.out.println("Success Message");
} else if (toastr_success_fail.equals("toast toast-error")) {
System.out.println("Fail Message");
} else {
System.out.println("Other Message");
}
System.out.println(validationMessage);
testResult = validationMessage;
}
} catch (Exception e2) {
testResult = "Toast message is not generated.";
testlog.info(testResult);
System.out.println(testResult);
}
return testResult;
}
You can get toast message and define Success/Fail operation:
By toastContainer = By.xpath("//div[@id='toast-container']//*");
By toastMessageDA = By.xpath("//div[@class='toast-message']");
public String toastUtility() throws Exception {
toast_container_flag = false;
try {
if (driver.findElement(toastContainer).isEnabled()) {
toast_container_flag = true;
List<WebElement> findData = driver.findElements(toastContainer);
for (WebElement element : findData) {
if (element.getAttribute("class").toString().contains("toast toast")) {
toast_success_fail = element.getAttribute("class").toString();
}
}
validationMessage = "Toast: " + driver.findElement(toastMessageDA).getText();
js.executeScript("arguments[0].click();", driver.findElement(toastMessageDA));
if (toastr_success_fail.equals("toast toast-success")) {
System.out.println("Success Message");
} else if (toastr_success_fail.equals("toast toast-error")) {
System.out.println("Fail Message");
} else {
System.out.println("Other Message");
}
System.out.println(validationMessage);
testResult = validationMessage;
}
} catch (Exception e2) {
testResult = "Toast message is not generated.";
testlog.info(testResult);
System.out.println(testResult);
}
return testResult;
}
answered Nov 13 at 7:16
Ishita Shah
2,0451324
2,0451324
add a comment |
add a comment |
up vote
0
down vote
Retrieval of toast messages is already supported for Android. Please look at the below release notes for Android.
https://github.com/appium/appium/releases/tag/v1.6.3
You need to use UIAutomator2 to work with toast messages in Android.
Hope this helps.
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
add a comment |
up vote
0
down vote
Retrieval of toast messages is already supported for Android. Please look at the below release notes for Android.
https://github.com/appium/appium/releases/tag/v1.6.3
You need to use UIAutomator2 to work with toast messages in Android.
Hope this helps.
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
add a comment |
up vote
0
down vote
up vote
0
down vote
Retrieval of toast messages is already supported for Android. Please look at the below release notes for Android.
https://github.com/appium/appium/releases/tag/v1.6.3
You need to use UIAutomator2 to work with toast messages in Android.
Hope this helps.
Retrieval of toast messages is already supported for Android. Please look at the below release notes for Android.
https://github.com/appium/appium/releases/tag/v1.6.3
You need to use UIAutomator2 to work with toast messages in Android.
Hope this helps.
answered Nov 13 at 11:10
Vinod
714313
714313
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
add a comment |
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
Please tell me how to install UIAutomator2?
– Navya Chinnari
Nov 14 at 5:20
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
@NavyaChinnari Please update your Android SDK. If you already have updated sdk, then you can directly start using UIAutomator2.
– Vinod
Nov 15 at 6:03
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260481%2fhow-to-automate-a-toast-message-in-appium-without-taking-screen-shot%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
You can get toast message text and verify it as expected
– Ishita Shah
Nov 12 at 11:11
Could u please tell me, how can we achieve that?
– Navya Chinnari
Nov 13 at 7:03
you can refer below example.
– Ishita Shah
Nov 13 at 7:16
How can we get toast message XPATH? (Regarding 1st two lines of code)
– Navya Chinnari
Nov 13 at 7:22
That you have to inspect it anyhow, It is bit complex, But it can inspect.
– Ishita Shah
Nov 13 at 7:24