FlubuCore | cross platform build and deployment automation system | Automation library
kandi X-RAY | FlubuCore Summary
Support
Quality
Security
License
Reuse
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
FlubuCore Key Features
FlubuCore Examples and Code Snippets
Trending Discussions on Automation
Trending Discussions on Automation
QUESTION
We are building web components using stencil. We compile the stencil components and create respective "React component" and import them into our projects.
While doing so we are able to view the component as expected when we launch the react app. However when we mount the component and execute test cases using cypress we observe that the CSS for these pre built components are not getting loaded.
cypress.json
{
"baseUrl": "http://localhost:3000",
"projectId": "263jf8",
"component": {
"componentFolder": "src",
"testFiles": "**/*spec.{js,jsx,ts,tsx}",
"viewportHight": 1200,
"viewportWidth": 1000
},
"retries": {
"runMode": 2,
"openMode": 0
}
}
sample spec file
import Header from './header';
describe('header', () => {
beforeEach(() => {
mount(
)})
it('renders as an inline button', () => {
cy.get('button')
.should('have.class', 'nexus-btn').and('be.visible')
cy.get('.nexus-hamburger-icon').should('have.text','Close Menu').and('be.visible')
cy.get('.nexus-menu > .nexus-btn').should('have.text','Close Menu')
cy.get('a > .nexus-visually-hidden').contains('Home')
cy.contains('Home').should('exist')
cy.get('a > .nexus-icon > svg').should('be.visible')
})
})
plugin/cypress.index.js
module.exports = (on, config) => {
require('cypress-grep/src/plugin')(config)
if (config.testingType === 'component') {
require('@cypress/react/plugins/react-scripts')(on, config)
}
return config
}
ANSWER
Answered 2022-Feb-16 at 02:33You can try importing the css in the index.ts or index.js file that will be available in the location -> cypress/support/index.ts
QUESTION
I am coding a voice assistant to automate my pc which is running Windows 11 and I want to open apps using voice commands, I don't want to hard code every installed app's .exe
path. Is there any way to get a dictionary of the app's name and their .exe
path. I am able to get currently running apps and close them using this:
def close_app(app_name):
running_apps=psutil.process_iter(['pid','name'])
found=False
for app in running_apps:
sys_app=app.info.get('name').split('.')[0].lower()
if sys_app in app_name.split() or app_name in sys_app:
pid=app.info.get('pid')
try:
app_pid = psutil.Process(pid)
app_pid.terminate()
found=True
except: pass
else: pass
if not found:
print(app_name + " is not running")
else:
print('Closed ' + app_name)
ANSWER
Answered 2022-Mar-02 at 09:40This can be accomplished via the following code:
import os
def searchfiles(extension, folder):
with open(extension[1:] + "file.txt", "w", encoding="utf-8") as filewrite:
for r, d, f in os.walk(folder):
for file in f:
if file.endswith(extension):
filewrite.write(f"{r + file}\n")
searchfiles('.exe', 'H:\\')
QUESTION
webElement.SendKeys(Keys.Control + "t");
This code is not working for me.String n = Keys.chord(Keys.CONTROL, Keys.ENTER);
driver.findElement(By.id("open-tab")).sendKeys(n);
In whichkey.chord
is not working for selenium C#.driver.SwitchTo().Window(driver.WindowHandles[0]);
this one is also not working with my code. Is any alternative way available for switching tab.
ANSWER
Answered 2022-Mar-19 at 15:25Selenium 4 solution:
driver.SwitchTo().NewWindow(WindowType.Tab);
Note that it will open a new tab in the same window and will switch also to the newly opened tab.
to open a new window, you should use:
driver.SwitchTo().NewWindow(WindowType.Window);
Selenium 3 solution:
((IJavaScriptExecutor)driver).ExecuteScript("window.open()");
List tabs = new List (driver.WindowHandles);
driver.SwitchTo().Window(tabs[1]);
QUESTION
I'm coming across an issue where once my test card number is typed into the first iframe the test tries to target the 2nd iframe (CVC) & it times out whilst trying to target the element. All info is listed below. Any help to why this is failing is appreciated!
Custom commands used:
// Make the iframe command return the body contents once it’s loaded
Cypress.Commands.add("iframe", { prevSubject: "element" }, ($iframe) => {
return new Cypress.Promise((resolve) => {
$iframe.on("load", () => {
resolve($iframe.contents().find("body"));
});
});
});
Commands for targeting the card number & CVC for guest users
// Checkout Add Card New Customer Card Number
Cypress.Commands.add(
"addCardNewCustomerCybersourceCardNumber",
({ cardNumber, expiry }) => {
// Card number iFrame
cy.get("#cardNumber-container > iframe")
.iframe()
.find('input[name="number"]')
.should("be.visible")
.should("have.attr", "placeholder", "Enter card number")
.type(cardNumber);
// Expiry date is not an iframe
cy.get("[data-cy=expiryDate]").type(expiry);
}
);
// Checkout Add Card New Customer CVC
Cypress.Commands.add("addCardNewCustomerCybersourceCVC", ({ cvc }) => {
// CVC iFrame
cy.get("#cvc-container > iframe")
.iframe()
.find('input[name="securityCode"]')
.should("be.visible")
.should("have.attr", "placeholder", "•••")
.type(cvc);
});
This are the 'it' statements from the test:
it("User adds new AMEX card for payment - Card number", () => {
cy.addCardNewCustomerCybersourceCardNumber({
cardNumber: "370000000000002",
expiry: "0330",
});
});
it("User adds new AMEX card for payment - CVC", () => {
cy.addCardNewCustomerCybersourceCVC({
cvc: "7373",
});
});
Here's a screenshot showing what the test is doing. It successfully finds the card input & fills it in but it fails for the CVC.
It then times out and the test cannot complete:
NOTE The selector it's trying to find is correct.
This also works when only trying to target the CVC field in a different scenario where a card number is not needed.
The code used for this is identical to the command that is having issues.
// Select Existing Card Cybersource
Cypress.Commands.add("selectExistingCardCybersource", ({ cvc }) => {
// CVC iFrame
cy.get("#cvc-container > iframe")
.iframe()
.find('input[name="securityCode"]')
.should("be.visible")
.should("have.attr", "placeholder", "•••")
.type(cvc);
});
Any idea what is going wrong? This is quite a big blocker.
EDITED TO INCLUDE THE FULL HTML.
Name on card
Card number
Expiry date*
Security code*
The last 3 digits on the back of your Credit or Debit card
(Amex 4 digits on the front).
Add this card to my wallet
Cancel and return
Pay Now
ANSWER
Answered 2022-Feb-15 at 19:59@BillBaily Thanks but I was looking for a larger piece of HTML, covering both iframes.
But another suggestion - I have seen on another project that uses WorldPay has nested iframes, so you would need something like
// Checkout Add Card New Customer CVC
Cypress.Commands.add("addCardNewCustomerCybersourceCVC", ({ cvc }) => { // CVC iFrame
cy.get("#cardNumber-container > iframe")
.iframe()
.within(() => {
cy.get("#cvc-container > iframe")
.iframe()
.find('input[name="securityCode"]')
.should("be.visible")
.should("have.attr", "placeholder", "•••")
.type(cvc)
})
})
But the test where a card number is not needed contradicts this theory, but worth mentioning in case the page structure differs between the two scenarios.
(BTW what payment library is being used?)
I just noticed that in the last screenshot the CVC field has indeed got focus, but name and expiry are empty.
This looks like validation may be preventing anything from being typed into the field. You can check that out by manually trying to only enter the CVC.
Try this for the test
it("User adds new AMEX card for payment - CVC", () => {
cy.addCardNewCustomerCybersourceCardNumber({
cardNumber: "370000000000002",
expiry: "0330",
})
// May need a name as well
cy.addCardNewCustomerCybersourceCVC({
cvc: "7373",
})
})
Or (as a last resort) use .type(cvc, {force:true})
in addCardNewCustomerCybersourceCVC
.
QUESTION
I want to prevent removing screenshots in Cypress. Each time the previous one is getting removed.
How can I prevent that in Cypress?
Because I want to keep all screenshots.
/Users/mac/cypress/cypress/screenshots
ANSWER
Answered 2022-Mar-13 at 08:25In cypress.json
Set "trashAssetsBeforeRuns": false
QUESTION
I am trying to do a large data check for a database. Some fields in the database are hidden, so when I am doing the datacheck, I need to ignore all hidden fields. Fields are hidden based on conditional logic stored in the database. I have exported this conditional logic and have stored it in a dataframe in R. Now I need to automate the data check by somehow using the text string of a conditional argument to automate the script writing itself, which I do not think is possible, or finding a way around this problem.
Below is example code that I need to solve:
id <- c(1001, 1002, 1003, 1004, 1005, 1001, 1002, 1003, 1004, 1005)
target_var <- c("race","race","race","race","race", "race_other",
"race_other", "race_other", "race_other", "race_other")
value <- c(1, NA, 1, 1, 6, NA, NA, NA, NA, "Asian")
branching_logic <- c(NA, NA, NA, NA, NA,
"race == 6", "race == 6", "race == 6",
"race == 6", "race == 6")
race <- c(NA, NA, NA,NA, NA, 1, 1, 1, 6, 6)
data <- data.frame(id, var, value, branching_logic, race) %>%
mutate(data_check_result = case_when(
!is.na(value) ~ "No Missing Data",
is.na(value) & is.na(branching_logic) ~ "Missing Data 1",
is.na(value) & race == 6 ~ "Missing Data 2",
is.na(value) & race != 6 ~ "Hidden field",
))
It would be great if I could replace (race==6) with a variable or somehow directing the script to the conditional expression already saved as a string, but I know that R can't do that.
The above problem has four categories which the data could fall into:
- No Missing Data: only if value is non-na
- Missing Data 1: if the value is NA, and there is no branching logic that hid the variable.
- Missing Data 2: if the value is NA and the branching logic is met to show the field
- Hidden Field: if the value is NA and the branching logic is NOT net to show the field
I have thousands of fields to check with accompanying branching logic, so I need a way to use the branching logic saved in the "branching_logic" column within the script.
IMPORTANT NOTE: The case here is the simplest case. Many target_var variables and value variables have branching logic that looks at multiple other variables to determine whether to hide the field (Ex. race==6 & race==1)
This is only my second time posting, and I usually do not see such in depth problems here, but it would be great if someone has an idea!
ANSWER
Answered 2022-Mar-08 at 02:31You can store the expression
you want to eval
uate as a string
if you pass it into parse()
first as explained in this answer.
Here's a simple example of how you can store the expression
in a column and then feed it to dplyr::case_when()
.
library(tidyverse)
set.seed(1)
d <- tibble(
a = sample(10),
b = sample(10),
c = "a > b"
)
d %>%
mutate(a_bigger = case_when(
eval(parse(text = c)) ~ "Y",
TRUE ~ "N"
))
#> # A tibble: 10 x 4
#> a b c a_bigger
#>
#> 1 9 3 a > b Y
#> 2 4 1 a > b Y
#> 3 7 5 a > b Y
#> 4 1 8 a > b N
#> 5 2 2 a > b N
#> 6 5 6 a > b N
#> 7 3 10 a > b N
#> 8 10 9 a > b Y
#> 9 6 4 a > b Y
#> 10 8 7 a > b Y
Created on 2022-03-07 by the reprex package (v2.0.1)
QUESTION
I have just created a spec file under that path is integration>mweb>account>address-mweb.spec.ts. Cypress UI sees my all spec files but while running it cannot establish a connection with tests.
How can I fix this, any idea?
p.s there is no network issue.
ANSWER
Answered 2022-Feb-28 at 07:21Update the cypress version to the latest. It might help you to fix the issue.
QUESTION
I've gone through Github Rest API v3 and Github GraphQL API v4 but I'm unable to find a resource/endpoint to check if dependabot is enabled via the API? I've gone through loads of documentation but was unable to find anything helpful. Could someone please point me to the correct document or tell me which resource to use? Thanks!
ANSWER
Answered 2021-Aug-04 at 13:30There was a dependabot API docs that could have helped, but it was deprecated in August 3rd 2021.
However, a workaround would be to check if the dependabot.yml
file is present in your repository or not using a GET
request to api.github.com/repos/name/repo/contents/fileNameOrPath
.
QUESTION
Is it possible to create a truly unique directory name (i.e. based on uuid) that is shorter then the default guid format?
so far I've been able to come up with this:
function Get-UglyButShortUniqueDirname {
[CmdletBinding()]
param ()
$t = "$([System.Guid]::NewGuid())".Replace("-", "")
Write-Verbose "base guid: $t"
$t = "$(0..$t.Length | % { if (($_ -lt $t.Length) -and !($_%2)) { [char][byte]"0x$($t[$_])$($t[$_+1])" } })".replace(" ", "").Trim()
Write-Verbose "guid as ascii: $t"
([System.IO.Path]::GetInvalidFileNameChars() | % { $t = $t.replace($_, '.') })
Write-Verbose "dirname: $t"
$t
}
With this I can generate directory names that look weird but take only about ~16 characters, which is way better than the default 32 characters of a plain guid (without dashes).
The thing I'm a bit concerned about: as 'invalid file name characters' are stripped and replaced with dots, those identifiers do not hold up to the same "uniqueness promise" as a guid does.
(struggling with legacy 260 char path-name limitations in Win-based automation environments :-/)
ANSWER
Answered 2022-Jan-28 at 14:45Convert your quid to Base64 which gives you a 24 characters string and (as mentioned by zett42) it is required to replace the possible slash (/
). besides, you might save another two characters by removing the unnecessary padding:
[System.Convert]::ToBase64String((NewGuid).ToByteArray()).SubString(0,22).Replace('/', '-')
zp92wiHcdU+0Eb9Cw2z0VA
BUT, there is actually a flaw in this idea: folder names are case insensitive, meaning that the folder naming might not be as unique as the original guid
.
Therefore you might want to fall back on Base32
(which needs 26 characters), which is a little more complex as there is no standard .Net method for this:
$Chars = ('A'..'Z') + ('2'..'7')
$Bytes = (New-Guid).ToByteArray()
$Bits = -join $Bytes.ForEach{ [Convert]::ToString($_, 2).PadLeft(8, '0') }
-Join ($Bits -Split '(?<=\G.{5})').foreach{ $Chars[[Convert]::ToInt32($_, 2)] }
DZ77OUQNDRQUTGP5ATAM7KCWCB
You might do something similar to include special characters, but I would be very careful about that as not every file system might support that.
QUESTION
in my cypress script i'm importing files as i'm doing page object models like this
import { LoginPage } from '../../page-objects/admin/login-page/LoginPage'
import {Common} from '../../page-objects/common/Common'
But my test fail on gitlab as it tries to import from another directory
Error: Can't walk dependency graph: Cannot find module '../../page-objects/common/Common' from '/builds/user/project_name/cypress/integration/landing-page/login.js'
required by /builds/user/project_name/cypress/integration/landing-page/login.js
ANSWER
Answered 2022-Jan-23 at 02:40See import statements are case-insensitive on Mac and Windows but case-sensitive on Linux.
Since Gitlab is running linux, try matching the file name exactly
import {Common} from '../../page-objects/common/common'
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install FlubuCore
For .NET Framework projects use FlubuCore.Runner
For .NET Core projects use FlubuCore CLI global tool
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page