protractor does not recognize '\' at uploading a file - jasmine

I've been reading a few answers to this and implemented one of those. Here is my code:
var path = require('path');
var fileToUpload = "C:\Users\patricio.lussenhoff\Desktop\test.txt",
absolutePath = path.resolve(__dirname, fileToUpload);
var type3 = browser.element(by.css('[type="file"]'));
type3.sendKeys(absolutePath);
The protractor apparently is not recognizing the slashes (I've tried '/' way too)
and the control shows like this:
here is the example I'm talking about
Any thoughts ?

Try it:
var fileToUpload = "C:\\Users\\patricio.lussenhoff\\Desktop\\test.txt";
var type3 = browser.element(by.css('[type="file"]'));
type3.sendKeys(fileToUpload);
This way you don't need to use 'path.resolve' because you are passing the complete and correct path.

Based on the OS Use single forward slash(Linux, Unix, etc.,) or double backward slash(Windows) to read files:
var fileToUpload = "C:/Users/patricio.lussenhoff/Desktop/test.txt",
var fileToUpload = "C:\\Users\\patricio.lussenhoff\\Desktop\\test.txt",

Related

Looping over a dynamic range in Google apps script to replace certain values

I've been getting problems trying to reference a dynamic range in google sheets to apply my function to: essentially replacing special characters and empty cells within a given data range with 0s, works perfectly if I gave it a static range but cant seem to do a dynamic one. Thanks alot for any help offered
Code thus far:
function replaceValues() {
var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var lastRow = sheet1.getDataRange().getLastRow()
var firstRow = sheet1.getDataRange().getRow("B2")
var targetValue1 = '-'
var targetValue2 = ''
var targetValue3 = '$'
var subValue = 0
for(var i =0; i=targetValue1; i++); {
var valueRng = sheet1.getRange(firstRow,lastRow);
var newValues = valueRng.getValues()[i].setValues(subValue);
}
}
Select the range before going the the menu and executing the function or build a modeless dialog and you can make the selection and capture on the custom dialog with a button click.
Demo:
If you have a range, you can do search and replace inside it this way:
range.createTextFinder('aaa').replaceAllWith('b');
Or with RegExp:
range.createTextFinder('a+').useRegularExpression(true).replaceAllWith('b');
I still don't understand what exactly you're trying to gain. So here is a guess how your script might look like:
function replaceValues() {
var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var range = sheet1.getDataRange(); // is the range dynamic enough?
// replace '$' and '-' with '0'
range.createTextFinder("[\$-]").useRegularExpression(true).replaceAllWith('0');
// replace '' with '0'
var data = range.getValues();
data.forEach((row,r) => row.forEach((cell,c) =>
data[r][c] = data[r][c].toString().replace(/^$/,'0')));
range.setValues(data);
}

Exporting Makehuman.js Three.js using THREE.OBJExporter

I am using https://github.com/makehuman-js/makehuman-js
The example exports the mesh from the source. So I am trying to get it from the scene with where it is changed.
When I try to export my scene to an obj file it is empty:
var objscene = new THREE.OBJExporter().parse( self.scene );
var output = JSON.stringify( objscene, null, 2 );
saveAs (new Blob([output], {type : 'text/plain;charset=utf-8'} ), 'Avatar.obj');
I can count the objects in the scene. There are four.
var scene_size = app.scene.children.length;
var i = 0;
while(i < scene_size){
alert(app.scene.children[i])
i = i + 1;
}
However they have no names so I add a name to my main human object.
// HUMAN
this.human = new makehuman.Human(this.resources);
this.human.name = 'human';
So now I can retrieve the name of the object named human.
var scene_size = app.scene.children.length;
var i = 0;
while(i < scene_size){
var thisone = app.scene.children[i]
alert(thisone.name)
i = i + 1;
}
So, I can demonstrate the objects exist. I will assign names to the other objects later. What I cannot understand is why my export is empty. The file is 1kb in size and there is only "" in it when I open it in my editor.
Any insight would be appreciated. I've been pounding it for a week and I am at a loss... Thanks!
OBJExporter.parse() does not return a JSON object. So it makes no sense to use JSON.stringify() in this context. Have a look at the actual output in this example (you will see it's just a plain string).
In any event, I recommend to use GLTFExporter instead since glTF is the recommended format of three.js. You can use code snippets from the following example for your own project.
https://threejs.org/examples/#misc_exporter_gltf

script to sort sheet by 2 colums

Please help make the script. As written below, I wrote a script that worked for some time. Now it does not work and I need help writing a new one.
The challenge is this: when you make changes in column F, K and O - occurs first check the availability of the text in the column to the - then if there is a text should start sorting first by F column - then sorting by a column O
There is a scheme of action sequences by the link:
https://drive.google.com/file/d/0B5qSx6LqB8U-d01URS1BcEVtNGs/view?usp=sharing
I will be happy if someone can help me.
In any case, thanks for your time and attention :) Have a nice day :)
29/03/17 I need help "Service error: spreadsheets"
A very recently worked script:
function onEdit() {
var ss = SpreadsheetApp.getActiveSheet();
var r = SpreadsheetApp.getActiveRange();
var cols = r.getColumn();
var rows = r.getRow();
var who = ss.getRange(rows,11).getValue();
if (who !== "") {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0]
sheet.sort(6);
sheet.sort(15);}
}
Today received an error:
Service error: spreadsheets
The script stopped working at all, help, please.
I'm not following how this completes your action sequence flow chart, but I believe this should get it running as before. I've seen other posts where people get this same Service Error message form previously working scripts, and I believe Google is trying to change how certain tasks are done to help their server loads.
function onEdit() {
var ss = SpreadsheetApp.getActive();
var r = SpreadsheetApp.getActiveRange();
var cols = r.getColumn();
var rows = r.getRow();
var who = ss.getActiveSheet().getRange(rows,11).getValue();
if (who !== "") {
var sheet = ss.getSheets()[0];
sheet.sort(6);
sheet.sort(15);}
}
I removed the duplicate definition of var ss and tweaked var ss, var who and var sheet to work without it.

TTTAttributedLabel addLinkToURL NSRange confusion

I am making a swift app and I want to add a url to a TTTAttributedLabel. I have got addLinkToUrl but it wants a NSRange. What should I put. I am new to swift. I want the url to be for the entire text.
//PersonTalking is a TTTAttributedLabel
var characterSpeaking:NSDictionary = item["characterspeaking"] as NSDictionary
var characterSpeakingString:String = characterSpeaking["text"] as String
var characterHref:String = characterSpeaking["href"] as String
var characterUrl = NSURL(string: characterHref)
println(characterSpeakingString)
PersonTalking.text = characterSpeakingString
PersonTalking.addLinkToURL(characterUrl, withRange: )
What can I do?
Thanks
If the link is meant to include the full label, then your range should be the full length of your text.
PersonTalking.addLinkToURL(characterUrl,
withRange:NSMakeRange(0,
countElements(characterSpeakingString))

Break line in long label text

Is there any trick to break a label text? Because '\n' '\r' '\n\r' don't work.
Many Thanks
if you use those 2 parameters you do what you want don't you ?
app.createLabel(text).setWidth(width).setWordWrap(true)
here is an example (among other widgets ;-):
function showurl() {
var app = UiApp.createApplication();
app.setTitle("Anchor in a popup ;-)");
var panel = app.createFlowPanel()
var image = app.createImage('https://sites.google.com/site/appsscriptexperiments/home/photo.jpg').setPixelSize(50, 50)
var link = app.createAnchor('This is your link', 'https://sites.google.com/site/appsscriptexperiments/home');
var lab = app.createLabel("wrap it because it's too narrow").setWidth(90).setWordWrap(true);
var quit = app.createButton('quit');
panel.add(image).add(link).add(lab).add(quit);
app.add(panel);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
EDIT : I found an old post(on the Google group forum, thanks again Henrique ;-) about breaking lines in toast messages and here is the code I used for that case... the principle should work for Labels too but I didn't try.
To use it, just use \n (where you want to break the line) in a variable containing your text and pass it through this function. (there are some comment in the script to explain)
function break_(msg){
var temp = escape(msg);// shows codes of all chars
msg = unescape(temp.replace(/%20/g,"%A0")); // replace spaces by non break spaces
temp = msg.replace("\n"," "); // and replace the 'newline' by a normal space
return temp; // send back the result
}
Would something like this work?
//takes a line of text and returns a flex table broken by \n
function breakLabel(text) {
var app = UiApp.getActiveApplication();
var flexTable = app.createFlexTable();
text = text.split('\n'); // split into an array
for (var i=0; i<text.length; i++){
flexTable.setWidget(i, 0, app.createLabel(text[i].toString()));
}
return flexTable;
}
Adding them to a vertical panel helps as well (not the way you want, but still..):
var vPanel = app.createVerticalPanel().setSize(100,100);
var label = app.createLabel('predominantly blabla blala blabla');
app.add(vPanel.add(label));
See reference
For anyone just now stumbling upon this, the best solution seems to be creating an HTML output for anything that needs line breaks.
Documentation
var htmlApp = HtmlService
.createHtmlOutput('<p>A change of speed, a change of style...</p>')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle('My HtmlService Application')
.setWidth(250)
.setHeight(300);
SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
// The script resumes execution immediately after showing the dialog.

Resources