Using await page.inputValue('input') to get the input value and it returns the actual value but how do i test for it?
I have tried something like this await expect(page.inputValue('input')).toHaveValue('10'); but that does not work.
You have to use this:
await expect(page.locator('input')).toHaveValue('10')
You can use this:
const value = await page.inputValue('input');
expect(value).toEqual('10')
or shorter
expect(await page.inputValue('input')).toEqual('10')
Related
I am trying to get a document from a form here, but my script out is missing. Am i doing anything wrong here. This seems to work when there is more than on argument but it is just one it seems not to be working
try:
documents = {}
if "Select which supporting documentation you would like to accompany your motivation letter" in input_data['checkbox']:
documents['doc1']="https://essentialmedicalguidance.s3.eu-central-1.amazonaws.com/brand/Eli+Lilly/Trulicity/VAE_Trulicity+Package+Insert.pdf"
return documents
except:
return {'empty' : True}
The function always has to return (or set) data. In the case where 'Select which...' is not in input_data['checkbox'], then nothing is returned.
Try something like this instead, which will be more consistent (if you add more fields):
result = {}
if 'Select which...' in input_data['checkbox']:
result['doc1'] = 'https://ess...'
return result
This way, your output is still conditional, but something is always returned.
for the following example i try to get Growth Rate for ticket in index C1:
=IMPORTXML(concatenate("https://www.gurufocus.com/term/dividend_growth_5y/",index(C1),"/5-Year-Dividend-Growth-Rate/"),"//*[#id="target_def_description"]/p[2]/strong[9]")
the data is in the following page:
https://www.gurufocus.com/term/dividend_growth_5y/T/5-Year-Dividend-Growth-Rate/ATT-Inc#:~:text=AT%26T's%20Dividends%20per%20Share%20for,Rate%20was%201.80%25%20per%20year.
please advice
10x
Y.
When I tested your formula using your URL, an error of Could not fetch url occurs. So in this answer, as a workaround, I would like to propose to use Google Apps Script for achieving your goal.
Sample script:
Please copy and paste the following script to the script editor of Spreadsheet, and put a custom formula of =SAMPLE(url) in a cell. By this, the script is run.
function SAMPLE(url) {
const res = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
if (res.getResponseCode() != 200) throw new Error(res.getContentText());
const meta = res.getContentText().match(/<meta name\="description"[\s\S\w]+?>/);
if (meta) {
const gr = meta[0].match(/ ([0-9.]+%)/);
if (gr && gr.length == 2) {
return gr[1];
}
}
return "Value cannot be retrieved.";
}
Result:
When above script is run for the URL of https://www.gurufocus.com/term/dividend_growth_5y/T/5-Year-Dividend-Growth-Rate/ATT-Inc#:%7E:text=AT%26T%27s%20Dividends%20per%20Share%20for,Rate%20was%201.80%25%20per%20year and https://www.gurufocus.com/term/dividend_growth_5y/T/5-Year-Dividend-Growth-Rate, the following result is obtained.
Note:
This sample script can be used for your URLs of https://www.gurufocus.com/term/dividend_growth_5y/T/5-Year-Dividend-Growth-Rate/ATT-Inc#:%7E:text=AT%26T%27s%20Dividends%20per%20Share%20for,Rate%20was%201.80%25%20per%20year and https://www.gurufocus.com/term/dividend_growth_5y/T/5-Year-Dividend-Growth-Rate. So when you change the URL, the script might not be able to be used. So please be careful this.
References:
Custom Functions in Google Sheets
Class UrlFetchApp
I am not sure what if anything I am doing wrong or if this is a bug.
My IndexedDB exists and has data in it. I am currently using alasql to query the data AFTER i retrieve it from IndexedDB, however I would much rather do this in a singe step as this make joins and other queries across multiple tables much simpler.
Here is my code:
const queryDB = async (dbName, query) => {
const result = await alasql.promise([
`CREATE INDEXEDDB DATABASE IF NOT EXISTS ${dbName};`,
`ATTACH INDEXEDDB DATABASE ${dbName};`,
`USE ${dbName};`,
]);
console.log(result);
return await alasql.promise(query);
};
(also tried without semicolon...)
the first call to this function fails with 'Error: Database ... does not exist' where ... is the dbName
while the second one succeeds and returns the value from the query.
I have been trying just about everything I can everything I can think of and the only working solution is using callbacks (as in the example on the wiki) which is NOT what I want to do.
Oddly enough this work:
const queryDB = async (dbName, query) => {
await alasql.promise(`ATTACH INDEXEDDB DATABASE ${dbName};USE DATABASE ${dbName};`);
return await alasql.promise(query);
};
I have a Map object
Map decodedresp = json.decode(response);
from here i get a list :
print(decodedresp['objectUrls']);
[{signedUrl: abc.com, path: a/b/c.log}]
now I want to get abc.com in a string, and I am not able to get it
I am learning dart and I am new to it
So, from what I can see it looks like you're dealing with parsed json.
In decoding json like you did json.decode(response) you're getting a:
_InternalLinkedHashMap<String, dynamic>
From that you are accessing objectUrls which returns a List<Map>. In order to deal with that you need to look for the key which in this case is signedUrl or path. Because your Map is wrapped in a List you need to get the element of the List.
This should work for you
Map<String, dynamic> decodresp = json.decode(response);
List<dynamic> objectUrls = decoderesp['objectUrls'];
// Zero here to get the first element, followed by the key.
var signedUrl = objectUrls[0]["signedUrl"];
var path = objectUrls[0]["path"];
You can see it working here
I could be wrong but because there isn't much info this is what I'm going with.
Let me know if you have any problems.
Felix.
I am using NativeScript-Dev-Appium#5.0.0 and wish to check for the text displayed on a label. I have automationText property assigned to the and use Driver.findElementByAccessibilityId(automationTextValue) to get the element. The element is found, but when I try to use the UIElement.text() / UIElement.getAttribute("value") on it, it returns the value of the automationText attribute instead of the actual displayed text. Is there any other method to do it because I can't find any.
Unfortunately, this is a limitation of NativeScript itself since when the automationText property is used, it will set all properties of the element like value, name, label etc. I would suggest you set the same text to automationText property and then you can access or test the element using something like this:
Using XPath:
const el = await driver.findElementByXPath("//*[#name=\"My automation text\"]");
For Android only
const el = await driver.findElementByText("My automation text");
const text = await el.getAttribute("text");
Use imageVerification types like:
await driver.compareRectangle
await driver.compareElement
await driver.compareScreen
Which is very convenient but the cons here is that this will require higher maintenance at some point.