Unable to close SysBoxForm in unit test X++ - axapta

When I close a SysQueryForm (by clicking on Ok button), a system generated dialog box appears on the form as shown below:-
I am writing a unit test to close this dialogue box but when I try to close the sysbox form by using the X++ code below:-
using (SysBoxFormAdaptor sysBoxForm = SysBoxFormAdaptor::attach())
{
sysBoxForm.CloseCtrl().click();
}
I am getting the following error:-
Cannot access form CPool id 3: topmost form is SysBoxForm id 181<\error>
There are open forms on the client: {"CPool (3)", "SysBoxForm (181)"}<\error>
To give a context, CPool is the form on which selecting a button opens a SysQueryForm and after selecting a criteria on the SysQueryForm for a particular table due to some join issue this system dialogue comes which cannot be fixed as of now.
I have tried some other ways as well but they too end up throwing the same error.
So the issue is that SysBoxForm is not closing.
Since this is a system generated (kernel level) dialogue, does anyone know how to close it?

So after further debugging I found out that two SysBoxForms are getting opened, one on top of the other. So closed them by attaching SysBoxFormAdaptor twice and it worked:-
using (SysBoxFormAdaptor sysBoxForm = SysBoxFormAdaptor::attach())
{
sysBoxForm.CloseCtrl().click();
}
using (SysBoxFormAdaptor sysBoxForm = SysBoxFormAdaptor::attach())
{
sysBoxForm.CloseCtrl().click();
}
This was the reason I was getting the error that a SysBoxForm is open.

Related

iOS_Appium_Java-Element is present but click operation is not interactable

We're trying to automate one of our Test cases on iOS (iPad) with appium-java client 8.
The test step is like below:
Fetch element from TextField
Click on that textField
Clear the existing value and enter the new value
Test Result:
We're able to fetch the value from the TextField
Click action is successful but the actual interaction is not working. Due to which the sendkeys also not working
Note: The above scenario was working fine with approach 1 with TestProject. Now we've migrated the framework to appium. After that only it's failing few scenarios
Please review the attached DOMAppium Inspector- Actual Element
Tried Approaches
1. Approach 1
{
element.getAttribute("value");
element.click();
element.sendkeys("newvalue");
}
->
Test Result:
We're able to fetch the value from the TextField
Click action is successful but the actual interaction is not working. Due to which the sendkeys also not working
2. Actions Class
{
Actions action = new Actions(appiumDriver);
WebElement element = appiumDriver.findElement(byLocator);
element.getAttribute("value");
action.moveToElement(element).click().perform();
action.moveToElement(element).sendKeys(Keys.chord(Keys.CONTROL, "a")).perform();
element.clear();
element.sendKeys(""+text);
appiumDriver.hideKeyboard();
}
Test Result:
We're able to fetch the value from the TextField
Click action is successful but the actual interaction is not working. Due to which the sendkeys also not working
3. With W3C action
{
PointerInput FINGER = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence tap = new Sequence(FINGER, 1)
.addAction(FINGER.createPointerMove(Duration.ofMillis(0),PointerInput.Origin.viewport(), (element.getRect().x + (element.getSize().width/2)), element.getRect().y))
.addAction(FINGER.createPointerDown(0))
.addAction(new Pause(FINGER, Duration.ofMillis(200)))
.addAction(FINGER.createPointerUp(0));
appiumDriver.perform(Arrays.asList(tap));
}
Test Result:
We're able to fetch the value from the TextField
Click action is working fine. However it's clicking on different location. Same thing happening when we try to find element in appium inspector. The locator is correct but still the coordinates are different one.
Find element with xpath-Highlighing coordinates

Dusk cannot dismiss dialog because of UnexpectedAlertOpenException

I am using Laravel Dusk to write browser tests for a Laravel 5.7 application. In the test I am navigating to the page and clicking a button which triggers a confirm dialog. I am trying to test that dismissing the dialog does not change the page url.
I have tried adding $this-expectException(UnexpectedAlertOpenException::class) before running the test to try to make the code understand a dialog should be shown
{
$this->expectException(UnexpectedAlertOpenException::class);
$this->browse(function (Browser $browser) {
$browser->loginToWave()
->goToSystemsEdit();
$browser->waitFor('#delete-systems-button')
->click('#delete-systems-button')
->assertDialogOpened('This will delete the system. Please seek advice before doing this. Continue?')
->dismissDialog()
->assertPathBeginsWith('systems/edit');
});
}
I expect the test to dismiss the dialog and check the path assertion.
What is actually happening is that an UnexpectedAlertOpenException is thrown:
1) Tests\Browser\Systems\DeleteSystemTest::testSystemNotDeletedIfConfirmIsDismissed
Facebook\WebDriver\Exception\UnexpectedAlertOpenException: unexpected alert open: {Alert text : This will delete the system. Please seek advice before doing this. Continue?}
(Session info: chrome=71.0.3578.98)
(Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.9.125-linuxkit x86_64)
/var/www/html/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:140
/var/www/html/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:326
/var/www/html/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:547
/var/www/html/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:345
/var/www/html/vendor/laravel/dusk/src/Browser.php:261
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:139
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/Collection.php:418
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:140
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:69
/var/www/html/tests/DuskTestCase.php:68

Can't figure how phone number reveal works

I am pretty new to web-scraping and recently I am trying to automatically scrap phone number for pages like this. I am not supposed to use Selenium/headless url browser libraries and I am trying to find the a way to actually request the phone number using let say a web service or any other possible solution that could give me the phone number hopefully directly without having to go through the actual button press by selenium.
I totally understand that it may not even be possible to automatically reveal the phone number in one shut as it is meant not be accessible by nosy newbie web-scraper like me; but I still like to raise the question for my information to get detailed answer from an expert point of view.
If I search the "Reveal" button DOM element, it shows some tags which I have never seen before. I have two main questions which I believe could be helpful for newbies like me.
1) Given a set of unknown tags/attribues (ie. data-q and data-reveal in the blow button), how is one able to find out which scripts in the page are actually using them?
2) I googled the button element's tag like: data-q and data-reveal the only relevant I could find was this which for some reason I don't have access two even-if I use proxy.
Any clue particularly on the first question is much appreciate it.
Regards,
Below is the href-button code
Reveal
Ok, according to your demand there are several steps before you finally get a solution.
1st step : open your own browser and enter your target page(https://www.gumtree.com/p/vans/2015-ford-transit-custom-2.2tdci-290-l1-h1/1190345514)
2nd step : (Assume you are using Chrome as your favorite browser) Press Ctrl+Shift+I to open the console, and then select 'Network' tag in the console.
3rd step : Press the 'Reveal' button on that page, watch the console carefully, catch the http request which is sent immediately when you press the 'Reveal' button. You can see the request contains a long string of number in Query String Parameters, actually it is a timestamp.
4th step : Also you can see there is a part named 'Request Headers' in that http request, and you should copy the values of referer , user-agent , x-gumtree-token.
5th step : Try to construct your request (I am a fan of Python, So I am going to show you my example code in Python)
import time
import requests
import json
headers = {
'referer': 'please enter the value you just copied from that specific request',
'user-agent': 'please enter the value you just copied from that specific request',
'x-gumtree-token': 'please enter the value you just copied from that specific request'
}
url = 'https://www.gumtree.com/ajax/account/seller/reveal/number/1190345514?_='
current_time = time.time()
current_time = str(current_time)
current_time = current_time.split('.')[0] + current_time.split('.')[1] + '0'
url += current_time
response = requests.get(url=url,headers=headers)
response_result = json.loads(response.content)
phone_number = response_result['data']

Receiving integral sign when using confirm dialog in atom-editor

For some reason, when I use the following code in package I'm trying to contribute to, an integral sign (∫) appears in the active document when a button is selected on the dialog.
checkAutoSave: ()->
if atom.workspace.getActiveTextEditor().isModified()
if atom.config.get('build.saveOnBuild') is true
atom.workspace.getActiveTextEditor().save()
return 1
else if atom.config.get('build.promptToSaveOnBuild') is true
diaDirection = atom.confirm
message: 'Do you want to save the current file before building?'
detailedMessage: 'This message can be turned off in the Build settings.'
buttons: ['Yes', 'No', 'Cancel Build']
switch diaDirection
when 0
atom.workspace.getActiveTextEditor().save()
return 1
when 1
return 0
when 2
return -1
else #Current File wasn't changed.
return 0
I have tried narrowing it down and I am 100% it has something to do with the dialog. The problem does not exists without the dialog call. The Integral sign appears in the document regardless of the button pressed.
I've had a similar problem a while ago - see here for more details.
The action I wanted to trigger in the editor was bound to Ctrl+Alt+B, which by default inserts the integral sign on Mac OS X. The integral sign was inserted into the currently open document when I opened a standard alert box from my package's code.
I didn't found out why, but it looks similar to your problem. In the end, I resolved it by removing the alert and using an Atom view instead for showing the message. As soon as I did this, the integral sign was no longer inserted into the document.
It looks like there's an issue with the key binding and preventing event propagation when using some dialogs. In some cases, the key event is handed to the OS and it inserts the character associated with the pressed key.
Maybe you can try using an Atom view instead of the confirm dialog, and it will resolve your issue as well.

Open print dialog for report from code

I am attempting to force open the print dialog so that all the user has to do is set the email address and press ok. I've found multiple tutorials on how to print a report to file or a printer without the print dialog, but that's not what I'm looking for.
Typically to email a report, the user displays the report, clicks the print icon in the tool bar, and then chooses email and sends it. I want to cut out the first two steps automatically.
This is one of my many attempts at doing this so far, but to no avail.
void emailInvoice()
{
Args args;
ReportRun rr;
Report rb;
PrintJobSettings pjs;
CustInvoiceJour record;
;
select record where record.RecId == 5637175089;
args = new Args("SalesInvoice");
args.record(record);
args.parmEnum(PrintCopyOriginal::OriginalPrint);
// Set report run properties
rr = new ReportRun(args,'');
rr.suppressReportIsEmptyMessage(true);
rr.query().interactive(false);
// set report properties
rb = rr.report();
rb.interactive(true);
// set print job settings
pjs = rr.printJobSettings();
pjs.fileName(strfmt("C:\\Users\\gbonzo\\Desktop\\%1.pdf", record.SalesId));
pjs.fitToPage(true);
// break the report info pages using the height of the current printer's paper
pjs.virtualPageHeight(-1);
// force PDF printing
pjs.format(PrintFormat::PDF);
pjs.setTarget(PrintMedium::Mail);
pjs.viewerType(ReportOutputUserType::PDF);
// lock the print job settings so can't be changed
// X++ code int the report may try to change the destination
// to the screen for example but this does not make
// sense when running a report here
pjs.lockDestinationProperties(true);
// Initialize the report
rr.init();
rr.run();
}
Thanks in advance for your help!
Have you tried to develop a RunBase standard dialog class (RunBaseBatchPrintable if you need to select the printer) that get all the dialog fields you need and from there, programatically run the report passing all the desired parameters? I'm prety sure it will work, and probably will left a cleaner code separating the report of the logic needed to the user interaction.
Read an example here:
http://waikeatng.blogspot.com.es/2010/10/using-runbasebatchprintable-class.html
You have to call the prompt() method of the ReportRun class before calling the run() method.
if (rr.prompt())
{
rr.run();
}
The prompt() method will show the print dialog. If you want it easier for your users you could use the SysMailer class, take a look to the quickSend() method.

Resources