Why does it appear "1:powershell" at terminal in react.js? - javascript

Why does it appear "1:powershell" at terminal in react.js?

If you would like to change this:
Open Visual Studio Code and press and hold Ctrl + ` to open the terminal.
Open the command palette using Ctrl + Shift + P .
Type - Select Default Profile.
Select your prefered terminal from the options (zsh/bash/ect).
Click on the + icon in the terminal window.
The new terminal now will be your prefered terminal (zsh/bash/ect).

Related

Save/copy to clipboard image from page by chrome console

For my project I need to copy image (not url, image name. Only data for ability, for example, to paste it to "Microsoft Paint") from page to clipboard by Chrome console.
I tried this:
copy(document.getElementById('someimage'));
but it returns nothing... It only works with text.
If you don't know, then how to download this image by chrome console?
OR
How to make screenshot of the page and copy or download it using Chrome console?
P.s. I can't use any js libraries.
I have explored few things in chrome dev tools
https://homeguides.sfgate.com/stop-air-flow-ceiling-air-diffuser-28867.html - This is the website I am using it for reference.
In Chrome console try the following command
imageurl= document.getElementsByTagName('img')[0].currentSrc;
copy (imageurl);
Note: Here you can change the img [1] array if you want to get different images
Then if you press ctrl + v in your keyboard you could see the image url with https. Please see the above screenshot.
You can perform the ctrl+ v on your new tab to get the image loaded.
or You can try the following method.
Right click the image and click inspect element
You could see some image url. Copy that URL
Open new Tab and paste the URL
If you right click on it you can see "Save Images" option.
Hope it will help you in someway.
As you mentioned you are using Selenium, here's how to save an image with Selenium:
You need to get the image's URL, load it (using ImageIO in this example) and save it. For example, in Java you would do something like this:
try {
driver = new ChromeDriver();
driver.get("http://...");
WebElement img = driver.findElement(By.cssSelector("#selector"));
BufferedImage buffer = ImageIO.read(new URL(img.getAttribute("src")));
ImageIO.write(buffer, "png", new File("image.png"));
} catch (Exception e) {
e.printStackTrace();
} finally {
driver.close();
}
If you want to copy it directly, your class needs to implement java.awt.datatransfer.ClipboardOwner and then you would do something like this:
try {
driver = new ChromeDriver();
driver.get("http://...");
WebElement img = driver.findElement(By.cssSelector("#selector"));
TransferableImage transferable = new TransferableImage(ImageIO.read(new URL(img.getAttribute("src"))));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, this );
} catch (Exception e) {
e.printStackTrace();
} finally {
driver.close();
}
Regarding your other questions, here's how to take a screenshot using Chrome DevTools:
There are 3 Capture... commands in Chrome DevTools. Just follow these steps to get to them:
Open DevTools.
Go to the Elements tab and click on the element you want to take the screenshot of.
Press Cmd + P on Mac or Ctrl + P on Windows.
Type > screen. You will get 3 relevant suggestions:
Mobile Capture full size screenshot: Captures the whole page, including the non-visible (out of viewport) area.
Mobile Capture node screenshot: Captures a single node, in this case, the element you clicked in the second step.
Mobile Capture screenshot: Captures the visible area of the page (viewport).
Click on any of them and the screenshot will download automatically.
However, keep in mind this feature doesn't always work fine, especially the Capture node screenshot one, so it might be better to capture the visible area of the page and crop the afterwards.

How to show console in jsfiddle

How can i display the console for debugging JavaScript on jsfiddle.net?
I only see a results tab. When trying to do a console.log('test'); only a white result tab appears.
Does a console panel exists at all?
Normally by pressing F12 or using inspect on your result pane.
Alternatively add
https://cdn.jsdelivr.net/gh/eu81273/jsfiddle-console/console.js
to the resources on the left as seen here
for (var i = 0; i < 5; i++) {
console.log(i); // 0, 1, 2, 3, 4
}
console.log({
foo: 'bar',
baz: function() {}
});
console.log([1, 2, 3]);
console.log(window.alert);
throw new Error('This is error log..');
<script src="https://cdn.jsdelivr.net/gh/eu81273/jsfiddle-console/console.js"></script>
Old answer
Until recently if you wanted the "Stacksnippet Console" type of console, you could choose jQuery and turn on Firebug which would show console messages in the result pane:
-- Latest Simple JSFiddle Solution --
JSFiddle now has its own beta settings for displaying the console:
which appears at the bottom of the results panel:
You can open it by right clicking and selecting Inspect Element on that menu or you can use f12 as a shortcut key to open console.
You can use the package below to redirect console output in an 'inspection style' manner to the HTML pane.
GitHub: https://github.com/karimayachi/html-console-output
If you also have normal HTML output, you can use CSS to overlay this console or have it stick to the top or bottom.
Basic example (no CSS) here: https://jsfiddle.net/Brutac/e5nsp2mu/
To run it inside jsFiddle, simply add the CDN-version (url below) to the resources (see example).
https://unpkg.com/html-console-output
you can use browser console by
Rightclick > inspect element > console
F12, opens the debugger view and on console tab you get the logs. You can filter as required warning/info/errors/all
(Tested on Chrome)
1- Write some simple JS code on the JS pane. e.g.> console.log("hello");
2- Click on "Run".
3- On the "Result" pane, right click and pick "Inspect".
4- Go to the Console.
5- Make sure that you filter your results.(See picture down below).
And do NOT click on "Update" in order to keep a clean console. Every time you want to test new code, just hit "Run" or use shortcut: Ctrl + Enter.

Powershell select ID element and click from web page

I am looking to open and click a button from a webpage in powershell.
The element I am selecting is:
<span class="x-btn-inner x-btn-inner-center" id="BtnExportCSV" unselectable="on">Export Dashboard as CSV File</span>
In the web console if I run the below code the button successfully clicks:
document.getElementById("BtnExportCSV").click();
The script I am running in powershell is below.
# open the specified web site and commit the key
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://wegpage.com/")
$ie.visible = $true
while($ie.busy) {sleep 1}
$doc = $ie.document
# commit the button
$commit = $doc.getElementById("BtnExportCSV")
if ($commit) { $commit.click() }
The webpage loads successfully, however the button does not click. Instead an error is produced:
You cannot call a method on a null-valued expression.
$commit = $doc.getElementByID("BtnExportCSV")
How do I get around this error? Any help greatly appreciated!
Lowercase the "d" in getElementByID("BtnExportCSV")
$commit = $doc.getElementById("BtnExportCSV")

Open a url in Windows Metro App via Javascript

Normally, when I use in my metro application, the url is opening in the default web browser. I don't want to do this with anchor, I want to do the same behavior via Javascript and as async. But I don't know how to open the url with default browser.
Here is my code:
var $aTag = $("<a/>").click(function (event) {
showYesNoDialog(
"Do you approve?",
"The link will be opened in another window. Do you approve?",
"Yes", // Text of yes button
"No", // Text of no button
function () { // Behavior of yes button
// I tried this but nothing happened.
window.location.href = _URL_; // Should open in chrome or default web browser
},
function () { // Behavior of no button
// do nothing
}
);
});
What I also tried is that:
$("<a href='" + _URL_ + "'></a>").click();
But this didn't work, too.
Finally, I found my answer while searching on google.
Open a URL in a new tab (and not a new window) using JavaScript
I used this code to open the url out the metro app and it worked in my situation:
window.open(_URL_, '_blank');
window.focus();
You cannot launch an actual application from within Metro, but what you can do is launch a file with associated program, and that should give you the functionality you need.
Check Sample
The sample covers files and URI's - http://msdn.microsoft.com/library/windows/apps/Hh701476

window.openDialog does not remove the titlebar on linux

I use the following code to display a popup:
var win = window.openDialog("chrome://broceliand/content/view/popup/nameMapPopup.xul",
"",
"all=no," +
"titlebar=no," +
"chrome=yes," +
"toolbar=no," +
"dialog=no," +
"resizable=no," +
"modal=yes," +
"dependent=yes," +
"top="+popupY+"px," +
"left="+popupX+"px",
args);
On windows the popup is pretty clean. There are no common elements remaining.
But on linux le titlebar still remains and the popup is resizable.
Try setting the hidechrome attribute on the window element to true. See https://developer.mozilla.org/en/xul/window
That might be because on Linux the window decorator is responsible for the titlebar. This can even be a seperate program to the window manager.
Does the popup need to be as a seperate window? Perhaps panel is really what you are looking for.

Categories