No longer able to us WebUI.GetText successfully from within Mailinator email body

So I believe Mailinator made a change over the weekend and a bunch of tests I had developed which Send emails out of an app we’re testing (and then flip into a mailinator inbox to verify that the email arrives, and then, at times, verify and grab text information presented in the email body).

Now, traditionally text in the mailinator email body is contained within an iFrame and I have an object that defines that iFrame and use the WebUI.switchToFrame to get into that email body at which point using objects to WebUI.GetText on has been pretty straightforward, however, some time between Friday Sept 4 and Sunday Sept 6 evening, all those steps are failing with the following error:

Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to get text of object ‘Object Repository/Data/Audit Trail/Mailinator/Email Text’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword.getText(GetTextKeyword.groovy:88)
at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword.execute(GetTextKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.getText(WebUiBuiltInKeywords.groovy:888)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$getText$8.call(Unknown Source)
at Verify Audit Trail List can be Exported.run(Verify Audit Trail List can be Exported:87)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1599514344398.run(TempTestCase1599514344398.groovy:23)
Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read property ‘clientWidth’ of null
(Session info: chrome=85.0.4183.83)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘LAPTOP-19G24CPJ’, ip: ‘192.168.0.15’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.38 (9047dbc2c693f…, userDataDir: C:\Users\jef\AppData\Local…}, goog:chromeOptions: {debuggerAddress: localhost:53422}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 97e2ff2d3241227ee6d64c0ce5bdfa87
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.getText(RemoteWebElement.java:166)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.lambda$new$0(EventFiringWebDriver.java:404)
at com.sun.proxy.$Proxy10.getText(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.getText(EventFiringWebDriver.java:463)
at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword$_getText_closure1.doCall(GetTextKeyword.groovy:80)
at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword$_getText_closure1.call(GetTextKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

In short, it looks like it’s not there and/or if it is it has a clientWidth of “null”

I double checked the object used for the Mailinator email body for the switch to Frame statement and it looks like it’s still correct:

//iframe[@id = ‘msg_body’ and @title = ‘Email Message Body’ and @name = ‘msg_body’ and (text() = ’
EMAIL BODY
’ or . = ’
EMAIL BODY
')]

Here’s a sample of a mailinator inbox that could be looked at (to put an email in it you’d have to send an email to audittrailexport@mailinator.com:

https://www.mailinator.com/v3/index.jsp?zone=public&query=audittrailexport#/#inboxpane

Once you open the email it looks like the normal iFrame for email body is present, but attempting to grab any text out of it is giving the error above.

sometimes text is in a

, or in a

.

I’ve tried using the object Spy to see if I can get a better description of the iFrame object OR objects within the iFrame - same issues
I’ve tried not switching to the iFrame and just seeing if I can Get the text from within the page (Maybe they removed the iFrame? - that doesn’t work
I’ve tried making slight tweaks to the iFrame object - no help so far
I’ve tried using the WebUI.GetAttribute command, but as the text appears to be loose in

s and

s there is no attribute I see to be able to attach to the object to get stuff when I am in the iFrame.
Interestingly, when I am in FireFox, and in Mailinator on a message, can right click and see that there is a Frame present that it detects, but when I attempt to open the Frame in it’s own tab or window I just get a completely blank page.

Uncertain what changed about mailinator over the weekend that has made getting text out of it’s email bodies so hard to pick up.

Has anyone had any issues getting text out of an iFrame before and what, if anything has worked?

Here is a sample snippet of my TC code that attempts to access the Mailinator inbox and grab some text from something that is throwing the error above:

WebUI.navigateToUrl(‘https://www.mailinator.com/v3/index.jsp?zone=public&query=methodaudittrailexport#/#inboxpane’)

WebUI.delay(3)

WebUI.click(findTestObject(‘Data/Audit Trail/Mailinator/First Email’))

WebUI.delay(3)

‘verify email is recieved and contains correct info’
WebUI.scrollToElement(findTestObject(‘Data/Audit Trail/Mailinator/Email Body’), 0)

WebUI.delay(1)

WebUI.switchToFrame(findTestObject(‘Page_Mailinator Main Site/iframe_EMAIL BODY’), 0)

‘download audit trail list’
WebUI.verifyElementPresent(findTestObject(‘Data/Audit Trail/Mailinator/Button_DownloadExport’), 0)

WebUI.verifyElementClickable(findTestObject(‘Data/Audit Trail/Mailinator/Button_DownloadExport’))

WebUI.delay(1)

CustomKeywords.‘clickUsingJS.clickingUsingJS’(findTestObject(‘Data/Audit Trail/Mailinator/Button_DownloadExport’), 5)

String fileName = WebUI.getText(findTestObject(‘Data/Audit Trail/Mailinator/Email Text’))

@j.theysmeyer

Do you want to get text of the highlighted element below?

If yes, please follow next

//iframe[@id = ‘msg_body’ and @title = ‘Email Message Body’ and @name = ‘msg_body’ and (text() = ’
EMAIL BODY
’ or . = ’
EMAIL BODY
')]

The iframe locator seems to be correct.

The root cause of the exception means that Selenium/Katalon could not use JavaScript on the null element:

Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read property ‘clientWidth’ of null
(Session info: chrome=85.0.4183.83)

Can you share the locator of Data/Audit Trail/Mailinator/Email Text test object?

The object I’d use in this case (and after switching to the iFrame) would probably look like this:
/html/body/div/text()

@j.theysmeyer

Please try to change Data/Audit Trail/Mailinator/Email Text locator to:

/html/body/div

or

/html/body

@duyluong Same issue when doing that

@duyluong - even just trying to perform a WebUI.VerifyTextPresent(‘hi there’, false) is telling me it’s not there, but it is when I view source.

I just using Katalon Recorder to record this page: https://www.mailinator.com/v3/index.jsp?zone=public&query=audittrailexport#/#inboxpane. The test ran well.

Capture_3

Here is the same project: mailinator.zip (15.2 KB)

@duyluong - Thank you very much for your assistance on this.

In fact the actual emails that I am sending and validating against are different than this plain text email and may be part of the issue (although there have been no recent changes to the emails). Here’s what seems to work though.

Replace the WebUI.getText statements with something like the following:

String code = WebUI.getAttribute(findTestObject(’<- insert object here ->’), ‘innerText’)

While there is no ‘innerText’ attribute explicitly being used on this object or visible in source, the getAttribute command is able to use this, along with the provided object, (and the switch into the iFrame) to find and return text, in this case returned to a String variable “code”, so that it can be passed around, validated, or used downstream in the script.

I’ve seen this in other objects that have changed (where text is no longer text on an object, but needs to be extracted from a WebUI.getAttribute statement, but usually there is a named attribute I can see the text value stored in and referenced in the statement. “innerText” appears to work for text that is just in a

or
1 Like

Hi –

Sam from Mailinator here !

We did indeed make a change as indicated, however to our surprise it was specifically around html
sanitization of email content. No changes to our site happened.

We’re very careful about ever changing HTML structure as we realize users depend on it. Typically we version the entire site when going to new HTML with old versions remaining available.

We’ve briefly looked at the issue above. If anyone has ideas of what happened, or what we can do to make things more identifiable we’d be interested in hearing them.

regards
Sam
samuel@manybrain.com

Hi @j.theysmeyer,
Thank you for sharing your findings. Our tests begon to fail also at 6thSept.
I can now again verify the content of emails using WebUI.getAttribute(,‘innerText’) instead of WebUI.getText()

2 Likes

My understanding is you want Item awarded text only. If so Try

//ul[@id=“mailcontainer”]/li[1]/a/div[2]
I also think, as per your comment, the content is inside an iframe. So all you have to use

driver.switchTo().frame(driver.findElement(By.cssSelector("[name=‘rendermail’]")));

String text = driver.findElement(By.cssSelector(“p:nth-child(3)”)).getText();

System.out.println(text);
Just tested. The code above works perfectly.