I am trying to assert if the language of a site matches the user language of the browser.
For web-driver, I think this can be done by getting the window.navigator.language and comparing it against the UI.
But how do I get the language of the browser in the IDE?
You can run JavaScript snippets using execute script.
For example: execute script | return window.navigator.language | browserLanguage
Related
I generated a VS Code web extension, registered the language into the package.json file, and put this code snippet into the extension.ts file:
console.log('activation');
context.subscriptions.push(vscode.languages.registerHoverProvider(selector, {
provideHover: function (document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.ProviderResult<vscode.Hover> {
console.log('hover');
return new vscode.Hover('test');
}
}));
If I start the extension by pressing the F5 key (it starts a new VS Code instance to run the extension), it works fine, but if I run the run-in-browser npm script it doesn't work. The activate function runs in both cases, because I see the text 'activation' in the console, but if I run in the browser I can't see the text 'hover'.
In normal (not web) VS Code extensions I can use both the VS Code API and the Language Server Protocol to implement language features like hover, formatting, go to definition etc. In the web extensions page they don't mention that I can only use the Language Server Protocol (and not the API) in web extensions, but in the only web extension sample where they implement language features, they use the Language Server Protocol.
So, is it possible to use the VS Code API to implement language features in web extensions, or I have to use the Language Server Protocol? If it's possible, why my code doesn't work in the browser but it does in desktop VS Code (using the web environment)?
Novice to Codemirror.
I have codemirror running on my server I have it set to Python mode. Can someone please suggest how I go about executing the code and showing the result on the page where I have written the python code
Thanks
Without knowing much about your setup, here's a general idea:
Use the getValue() method to get the code from your CodeMirror instance.
Assuming the code is a run-able Python script, you can either
(1) send the code to your back end with AJAX or a POST request and run it there. Or (2) you could run the Python script in the browser with a library like one discussed here.
If you ran it on the back end, you can send the result of running the code back as text or JSON with your preferred protocol. If you ran it on the browser, you should probably follow the guidelines for the specific library you used.
With the help of the Selenium IDE add-on for Firefox, I'm trying to publish a post on Facebook that will include a link, the post should also contain the usual 'link preview' (image and/or description text) scraped from the website I'm sharing.
For this purpose I played around with the following commands to no avail: "type" ; "typeKeys" ; "SendKeys"... the result was actually expected because these commands mimic typing, and if you manually write a link (by typing it) while trying to publish a post on Facebook - the "link preview" (image and/or description) won't be loaded. I also tried to emulate pressing "ctrl + [a/c/v]" in 3 separate commands as a workaround after the link as a text was written in the 'update your status' field, but no luck with those. See the visual examples below:
Selenium IDE contains:
Store | https://9gag.com/ | link
[[bunch of irrelevant commands in-between]]
typeKeys | class=_1mf _1mj | ${link}
Result:
Screenshot 1 - imgur
If you publish the post this way, it'll end up like a plain text. Not a valid share. The thing I'm trying to achieve with Selenium IDE is what's shown on the screenshot below. You can achieve it by copying some absolute URL and pasting it (ctrl + v) inside the 'update your status' window on Facebook.
Result:
Screenshot 2- imgur
Important: Workarounds are welcome as always, but here's what's not welcome as a workaround from other off-topic non-Selenium related reasons:
Using this sharing form: facebook.com/sharer/sharer.php?u=[absolute URL you want to share]
Using the mobile/touch version of Facebook
Thank you in advance for your time, and for the potential solution.
You could try using a space or enter at the end of the URL.
I am trying to parse html code from wicket application to Java. My application uses wicket and I found a method
tester.getLastResponse().getDocument()
which does just that. However not all html code gets included there. When I saved this output I can see that there are places like
< MARKUP FOR
com. ... .form.PlainCheckBoxPanel END
>
How can I make it parse the full html code?
It seems you run your application in DEVELOPMENT mode and org.apache.wicket.settings.DebugSettings#isOutputMarkupContainerClassName() returns true.
Change it to PRODUCTION mode or call org.apache.wicket.settings.DebugSettings#setOutputMarkupContainerClassName(false).
I am writing some Selenium RC tests using the perl library WWW::Selenium. At the beginning of the test I need to login to a web form using my username and password.
I noticed that my password is displayed in the Selenium Remote Control "Command History" window as type(password, secret).
Is there any way to suppress the display of the password? Maybe there is a command other than type I can use?
Unfortunately no. You could go into the Selenium core and change it to show ******* when it finds a field named password.
Beware though that this could make life difficult when debugging
I guess we can do this using native methods support.
Think logically every native methods in selenium will be sent to the operating system not to the browser.
So if you use any of the native methods, the flow is like this:
Client Program ----> Selenium RC server ----> to the operating system (in Java this is done using Robot Class)
But all the other non-native methods flow is like this:
Client Program ----> Selenium RC server ----> to the Browser
So, the Command History window operates at the Browser level and the native methods will not reach there.
Here is the code:
selenium.focus("locator");
selenium.keyPressNative("key code"); // this will not be shown in command history
Here the key code is only for one character and if you want string (more than one character), we should rely on our client program to implement the logic.
I have given that code in my previous answers to other posts. If you need it personalised post our exact requirement so that I can give that code tailored to your need.