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

TOAST validation #86

Closed
joaoclineu opened this issue Aug 12, 2013 · 14 comments
Closed

TOAST validation #86

joaoclineu opened this issue Aug 12, 2013 · 14 comments

Comments

@joaoclineu
Copy link

It is possible to do validation TOAST with Selendroid ?

@lukeis
Copy link
Member

lukeis commented Aug 12, 2013

+1 my app also uses TOAST, but I haven't been able to identify / locate it yet

@joaoclineu
Copy link
Author

This is a feature very important for validation

@lukeis
Copy link
Member

lukeis commented Aug 13, 2013

It would be helpful if you could look at how TOAST displays its messaging, or if you solicit an android developer. It would be a good start to know how exactly TOAST works.

@joaoclineu
Copy link
Author

The TOAST is an event that is sent from the execution of some other method. Toast is not a component part of the application layout. We need a method to visualize any text sent on the screen indepedente to be part of the layout or not. For example the the WAITFORTEXT robotium. But I do not know if this method has already Selendroid.

@lukeis
Copy link
Member

lukeis commented Aug 13, 2013

I understand that it is not apart of the application layout... thus why you can't see it in the inspector. Do you know what the "some other method" is. If I can get that info, then I'll likely be able to figure something out to get the messages.

@DominikDary
Copy link
Member

Are you able to find the TOAST, if you search in a loop for the text that is displayed?:
driver.findeElement(By.linkText("Enter Your Text of Toast");

@erbett
Copy link

erbett commented Aug 13, 2013

I put the statement in loop. Selendroid couldn't be able to validate the toast. Element wasn't found.

while (driver.findElement(By.linkText("Campo(s) não preenchido(s).")).isDisplayed()==true){
System.out.println("Toast is shown");
}

@joaoclineu
Copy link
Author

The command: driver.findeElement(By.linkText("Enter Your Text of Toast"); does not function.

@chiavegatto
Copy link

Is there a way to solve this problem with the newest version of Selendroid?

@sreevatsa-ramya
Copy link

I too have this question as i have tried using linktext but things don't work. Please let know when this issue would be solved

@gourav999
Copy link

webElement x=driver.findelementby(by.xpath("//Button[@id='showToastButton']");
x.click();

@sreevatsa-ramya
Copy link

Still unable to capture the toast message, Following is the console log output -

INFO: POST redirect to: http://localhost:8080/wd/hub/session/1dda4f0e-3c74-f58d-5c2d-f7df4410d3cc/elements
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler redirectRequest
INFO: Payload? {"using":"link text","value":"Expense successfully saved"}
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler handle
INFO: return value from selendroid android server: [{"ELEMENT":"67af8956-9a36-7000-64e3-d827c5da79f0"}]
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler handle
INFO: forward request command: for session 1dda4f0e-3c74-f58d-5c2d-f7df4410d3cc
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler redirectRequest
INFO: GET redirect to: http://localhost:8080/wd/hub/session/1dda4f0e-3c74-f58d-5c2d-f7df4410d3cc/element/67af8956-9a36-7000-64e3-d827c5da79f0/text
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler handle
INFO: return value from selendroid android server: {"message":"Element with id '67af8956-9a36-7000-64e3-d827c5da79f0' was not found.\nio.selendroid.exceptions.SelendroidException: Element with id '67af8956-9a...
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler handle
INFO: forward request command: for session 1dda4f0e-3c74-f58d-5c2d-f7df4410d3cc
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler redirectRequest
INFO: POST redirect to: http://localhost:8080/wd/hub/session/1dda4f0e-3c74-f58d-5c2d-f7df4410d3cc/elements
Mar 28, 2014 7:56:33 PM io.selendroid.server.handler.RequestRedirectHandler redirectRequest
INFO: Payload? {"using":"link text","value":"Expense successfully saved"}

Finding the toast is in while loop. Please help me with this ASAP.

@tarifulcse
Copy link

Please use following code in your selendroid code

waitForElement(By.partialLinkText("Your Toast message"), 4, driver);

where first parameter is your toast message. Second parameter is Time duration in Seconds,third is driver.

@asm89
Copy link
Member

asm89 commented Jun 29, 2015

We have a working e2e test covering this.

@Test
public void shouldWaitUntilToastIsDisplayed() throws Exception {
precondition();
driver().findElement(By.id("showToastButton")).click();
WebElement toast = waitForElement(By.linkText("Hello selendroid toast!"), 4, driver());
Assert.assertNotNull(toast);
}

@asm89 asm89 closed this as completed Jun 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants