Cypress: Custom command to read style of element failing - cucumber

I'm using cypress 10 and cucumber (https://www.npmjs.com/package/#badeball/cypress-cucumber-preprocessor). As a result a lot of similar questions/tutorials are not helpful as the file structure has change (no index.js in my support file for example).
My brain feels like a bunch of melted crayons, can someone look this over and tell me why my custom command isn't working?
Essentially I'm trying to create a custom command (accountMenuControl) that determines if a sliding menu (accountMenuDiv) is open or closed and then reacts or doesn't react depending on the situation. Sometimes I need it opened to select something from it. Sometimes I need it closed because it's obscuring something.
So again, ideally, I want to be able to just put in cy.accountMenuControl(open) and have it check if it's currently opened/closed and act accordingly.
The only way I've found to detect if it's open or closed is based on the style attribute (display: none is closed, display: block is open).
I'm very new to cypress so i'm sure i've got something obvious wrong.
This is in the pre-generated support/commands.js file
const accountMenuDiv = cy.xpath('//*[#id="sidebar"]/div[2]');
const accountMenuSwitch = cy.xpath('//*[#id="sidebar"]/div[1]/h3/i');
cy.get(accountMenuSwitch).then(() => {
if (desiredPosition = open) {
if (accountMenuDiv.should('have.style', 'display: block')) {
cy.wait(2000)
} else {
accountMenuSwitch.click()
cy.log("ACCOUNT MENU FOUND TO BE CLOSED - OPENING")
cy.wait(20000)
}
} else {
if (accountMenuDiv.should('have.style', 'display: none')) {
cy.wait(2000)
} else {
accountMenuSwitch.click()
cy.log("ACCOUNT MENU FOUND TO BE OPENED - CLOSING")
cy.wait(20000)
}
}
})
})
package.json
{
"devDependencies": {
"#badeball/cypress-cucumber-preprocessor": "latest",
"#bahmutov/cypress-esbuild-preprocessor": "^2.1.3",
"cypress": "^10.6.0",
"cypress-xpath": "^2.0.1",
"esbuild": "^0.15.5"
},
"cypress-cucumber-preprocessor": {
"json": {
"enabled": true
}
}
}
I'm getting 'shouldhave.style, display: block' and 'The chainer style was not found. Could not build assertion.' from cypress

Related

PDFTron Trigger Editing of Annotation for annotations when added

I have added a custom annotation and listened to annotationAdded event and select the annotation using below code.
instance.docViewer
.getTool("AnnotationCreateCustomStamp")
.on('annotationAdded',
function (a) {
instance.annotManager.selectAnnotation(a);
});
How should I trigger the edit mode on the annotation?
What does your 'AnnotationCreateCustomStamp' tool look like? Does it trigger an 'annotationAdded' action and get to your callback function?
You can open the note panel and start editing with the 'focusNote' API
instance.docViewer.getTool("AnnotationCreateCustomStamp").on('annotationAdded',
function (a) {
// assuming the code get here
instance.focusNote(a.Id);
})
);
Update:
For focusing on replies of selected annotations, you can use the getSelectedAnnotations method and do something like
instance.focusNote(docViewer.annotationManager.getSelectedAnnotations()[0].Id)
Or you can use the annotationSelected event and do something like
WebViewer(
{
// your configuration
}, document.getElementById('viewer'))
.then(function(instance) {
const { annotManager } = instance;
annotManager.on('annotationSelected', (annots) => {
if(annots && annots[0]) {
instance.focusNote(annots[0].Id);
}
});
})

Is there any way to close an overlay

I am using react-native-navigation v2 and showing an overlay,
and at some place in my code. i want to show an over lay and later disable it .
for example to show loading.
I have Read the docs and followed it as much I could understand. I can show an overlay but can not dismiss it. A warning always comes up saying - overlay with id offlineoverlay1 was not found.
async showOverLay(){
await Navigation.showOverlay({
component: {
id: "OfflineOverlay1",
name: 'Uploading',
options: {
overlay: {
interceptTouchOutside: true
}
}
}
});
}
async closeOverLay(){
await Navigation.dismissOverlay('OfflineOverlay1')
}
Expected Result- the overlay should be closed when calling closeOverLay() function
you have defined
component :{id:"OfflineOverlay1"} // the use of ""
but you have called like this,
Navigation.dismissOverlay('OfflineOverlay1') // & the use of ''

change fontfamily for output cells in jupyterlab

I would like to change the default fontFamily for all cells in jupyterlab. I was able to edit the configuration in Advanced Settings Editor for code, markdown and raw cells. But the output cells still use the default SourceCodePro font. Is there a way to change that too?
Apparently this feature is not implemented yet. See here: https://github.com/jupyterlab/jupyterlab/issues/5764
I got around this by first installing the extension jupyterlab-fonts and then changing the --jp-code-font-family parameter in the file ~/.jupyter/lab/user-settings/#deathbeds/jupyterlab-fonts/fonts.jupyterlab-settings to this:
{
// Fonts
// #deathbeds/jupyterlab-fonts:fonts
// Settings for JupyterLab Fonts
// *********************************
// Global Styles
// JSS-compatible JSON applied to the Global scope
"styles": {
":root": {
"--jp-code-font-family": "monospace"
}
}
}
In the jupyterlab open settings > Theme, on the overides change code-font-family
{
"overrides": {
"code-font-family": "monospace",
"code-font-size": "13px"
}
}

nodejs+selenium-driver NoSuchElementError & StaleElementReferenceError

I am doing a test based mocha. node v8.2.1, selenium-webdriver: ^3.5.0.
test.it('demoClass', () => {
driver.classes[0].findElement(By.css('.class-avatar')).click();
driver.wait(until.elementIsVisible(driver.findElement(By.css('.anticon.anticon-plus'))));
//driver.sleep(2000);
driver.findElement(By.css('.anticon.anticon-plus')).click();
})
I am getting two different types of errors, either its NoSuchElementError: no such element: Unable to locate element: or StaleElementReferenceError: stale element reference: element is not attached to the page document
But whichever error, its refer to line:
driver.findElement(By.css('.anticon.anticon-plus')).click();
When I use driver.sleep(2000), its getting resolved. In my opinion, It's the question of animation. I can get the element(.anticon.ancicon-plus) only at the time, the page's animation is completed.
what I am confused is that I use driver.wait(until.elementIsVisible()) without an error, It's obvious that I got the element. but at the next line, I can't use it. Or NoSuchElementError, or StaleElementReferenceError.
I find some answer like http://www.seleniumhq.org/exceptions/stale_element_reference.jsp,https://stackoverflow.com/questions/18225997/stale-element-reference-element-is-not-attached-to-the-page-document. But It can't help me.
when use driver.findElement, something terrible will be triggered. use javascript instead it.
driver.executeScript(function() {
while(true) {
if(!document.querySelector('.anticon.anticon-plus')){}
else {
document.querySelector('.anticon.anticon-plus').click();
break;
}
}
return true; // not neccessary
})

Why do I get a "connot be applied to 'Closure'" Warning in my gradle script?

I have a hard time figuring out, why IntelliJ warns me about this part in my build.gradle file:
apply plugin: 'distribution'
(...)
distributions {
main {
baseName = 'someName'
contents {
from { 'src/readme' }
}
}
}
shot:
I took it straight from the gradle user guide and the build seems to work ok. So, is this a false positive or should I take this serious? If so, what's the problem here and how would one check the API / code to find the expected types and so on?
it is a false positive, but if you want to make it disappear use the following
apply plugin: 'distribution'
distributions.create('someNameButMain', {
baseName = 'someName'
contents {
from { 'src/readme' }
}
})

Resources