I`m trying to write some tools with chrome Chrome DevTools Protocol https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-enable.
I want get page ResponseBody and I don't know where can I find RequestId. So here is my simple Ruby code:
chrome = ChromeRemote.client
# Enable events
chrome.send_cmd("Network.enable")
chrome.send_cmd("Page.enable")
puts chrome.send_cmd "Network.getCookies"
# for this command I need RequestId ->
puts chrome.send_cmd "Network.getResponseBody"
For now I have empty result for puts chrome.send_cmd "Network.getResponseBody".
You need to listen to the requestWillBeSent event, which would give you both URL and requestId
Every time a Protractor element locator fails, it prints an error and continues down a horrible path of endless cascading failures in my spec and suite. Every test that follows depends on the element locator finding its element, and depends on the current spec passing.
I would like to keep the web page under test open while I use the console. The goal is to debug the current state of the page and investigate why the element locator may have failed to find its target.
I'm not too concerned about failing the entire suite and exiting on the first spec failure (I've seen other answers on --fail-fast and stopping on first spec failure.) This is not the approach I would like to take. I want to set a breakpoint, and inspect the environment while the page is running.
Maybe there's something like a Jasmine option for doThisOnFailure: () => { debugger }, which would work for me I think.
I really do not like the solution of using a spec reporter to execute during afterEach and check the failed spec count on the Jasmine environment for the entire spec function. I want to immediately know when an element locator has failed and immediately break as soon as it has failed.
Maybe something really gross would work $('element').click().catch(() => { debugger }).
EDIT: Please, note that I am asking about breaking in a spec, not breaking at the end of the spec.
it('should execute deadly code', function () {
p.navigation.openStorageConfigTab()
$$('.bad-selector').get(0).click() /* IMPORTANT: I want to break here */
p.volume.navigateTo()
})
it('should not execute this spec', function () {
$$('.bad-selector').get(0).click()
})
And the output
✗ should execute deadly code
- Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator By(css selector, .bad-selector)
✗ should not execute this spec
- Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator By(css selector, .bad-selector)
I can recommend you the approach I use, and I hope you can take it from here
Overall approach is to wait until until you type close/ command in browser url:
await browser.waitForAngularEnabled(false);
await browser.wait(
async () => {
let url = await browser.getCurrentUrl();
return url.includes('close/');
},
5 * 60 * 1000,
'Keep-alive timeout reached, closing the session...'
);
The question is when you want to call it. I use the advantage of onComplete callback function in config file. When it's called, the browser is still available. So once all tests are completed, it doesn't exit for 5 minutes unless I submit close/ to the url field. Obviously that can be conditional, by adding something like if (DEBUG === true)
A downside of this setup is it's called when all tests are completed, and it's possible your spec has navigated away from the page where there was error. So what you can also do is to use advantage of jasmine reporter (if you use jasmine). Roughly, you just need to add this to your onPrepare func:
jasmine.getEnv().addReporter({
jasmineStarted: function(suiteInfo) {},
suiteStarted: function(result) {},
specStarted: function(result) {},
specDone: async function(spec) {
if (spec.status === 'failed') {
await browser.waitForAngularEnabled(false);
await browser.wait(
async () => {
let url = await browser.getCurrentUrl();
return url.includes('close/');
},
5 * 60 * 1000,
'Keep-alive timeout reached, closing the session...'
);
await browser.close();
process.exit(35);
}
},
suiteDone: function(result) {},
jasmineDone: function(result) {},
});
So if any it block has failed status, then it'll stop. BUT, I have not tested it, I'll leave it up to you. And second, I didn't think about what will happen to the rest of queued specs since you're redirected to non existing url close/, but I believe it'll still work for you. Worst case scenario, you can play around and make it continue or close the browser instance, as long as you understood the concept
P.S.
I modified the code to close the browser when you type close/, by adding
await browser.close();
process.exit(35);
I tested this code with the following scenarios:
happy path: all 5 it are successful
first element finder of second it block fails
second element finder of second it block fails
All passed. The code works as expected
I'm pretty new to Geb, but I'm facing an odd issue that the docs don't seem to address. I have a pretty simple scenario to test: log in as admin, open applications, verify that an 'apply' button appears on the home page. Then close applications and verify that the button is gone from the home page. I can perform this test manually with success and there is nothing on the server side (cache wise) preventing this from succeeding but when I run the test via Gradle it fails because the button is still being shown on the home page after the 'close' test. Note that the test also verifies that the config was saved with the proper value.
Here's my test code:
def "can open applications"(){
when:
to ManageConfigPage
and:
configFormModule.toggleApplications(true)
then:
at ManageConfigPage
assert $('#messages').text() == "Config successfully updated"
assert $('td', text: 'config.application_closed').closest('tr').find('input').value() == "0"
then:
to HomePage
assert applyButton
}
def "can close applications"(){
when:
to ManageConfigPage
and:
configFormModule.toggleApplications(false)
then:
at ManageConfigPage
assert $('#messages').text() == "Config successfully updated"
assert $('td', text: 'config.application_closed').closest('tr').find('input').value() == "1"
then:
to HomePage
assert !applyButton
}
Here's the applyButton content definition:
applyButton(cache: false, required: false){ $('#apply_button') }
I also tried using the selector directly in the test instead of inside a content definition and that did not work either.
So what's going on here? Is the home page being cached in it's entirety? If so, how do I prevent or refresh it? This seems like Geb 101 but the manual doesn't really address this issue.
Edit: adding the test result for completeness:
Condition not satisfied:
!applyButton
||
|applyButton - SimplePageContent (owner: HomePage, args: [], value: null)
false
at AdminSpec.can close applications(AdminSpec.groovy:59)
Is the button element not included in the html or is is simply hidden? If it's hidden then you will need to check that it's not displayed:
!applyButton.displayed
I'm using a VBScript to auto accept Skype incoming contact request:
Public Sub Skype_UserAuthorizationRequestReceived(ByVal pUser)
pUser.IsAuthorized = true
End Sub
This works but is there a way to prevent Skype from alerting me through the tray?
I have already removed notification for contact request:
but it still appears.
It's also giving me a strange error:
Skype4COM.Skype.1: Invalid value given to ISAUTHORIZED/ISBLOCKED (code: 80020009)
I tried another approach of using
oSkype.Client.OpenAuthorizationDialog(pUser.Handle)
but it's giving an 'OPEN User already authorized' error.
I got an example that might help you.
Private Sub FRAccept(pUser As User)
If FlatToggle1.Checked = True And pUser.IsAuthorized = False Then
pUser.IsAuthorized = True
End If
End Sub
I am having an issue with clicking on an OK button in a confirming dialog. This is what I have used but it isn't activating the OK nor is it getting the message property from the dialog. Any ideas as to what is wrong OR better yet, do you have any code that clicks on OK in a confirm dialog?
var confirmHandler = new ConfirmDialogHandler();
using (new UseDialogOnce(newIee.DialogWatcher, confirmHandler))
{
//Click EXIT - CT__Exit
Regex ex = new Regex("CT__Exit");
newIee.Image(Find.ById(ex)).ClickNoWait();
string temp = confirmHandler.Message;
confirmHandler.WaitUntilExists();
Assert.AreEqual(
"Warning! Policy Number or Transaction Type was changed."
+ " Are you sure you want to exit the case?",
confirmHandler.Message);
confirmHandler.OKButton.Click();
}
The script is failing here...confirmHandler.WaitUntilExists();