I'm trying to click on a webpage item via AppleScript but with no success.
I tried the following code in chrome and safari:
execute "document.getElementById('t-strikethrough').click();"
and
do JavaScript "document.getElementById('t-strikethrough').click();"
In Safari, the first line of code does nothing and the result section of Script Editor says missing value. With Chrome, I get the following error:
Can’t make "document.getElementById('t-strikethrough').click();" into
type specifier
This is included inside tell statements to locate app, window and document.
Without seeing all of your AppleScript code, it's difficult to see exactly what the problem is. You may want to try setting a variable for the URL like this:
set URL of document 1 to "http://www.whatever.com"
do JavaScript "document.getElementById('t-strikethrough').click();" in document 1
Check this post to see the full example . Click Button on Webpage with Applescript/JavaScript
Related
I am trying to build an automated Puppeteer script to download my monthly bank transactions from my bank website.
However, I am encountering a strange error (see attached Imgur for pictures of this behavior)
https://imgur.com/a/rSwCAxj
Problem: querySelector returns null on DOM element that is clearly visible:
Screenshot: https://imgur.com/d540E6p
(1) Input box for username is clearly visible on site (https://internet.ocbc.com/internet-banking/),
(2) However, when I run document.querySelector('#access-code'), console returns null.
I'm wondering why this behavior is so, and what are the circumstances that a browser would return null on a querySelector(#id) query when the DOM node is clearly visible.
# EDIT: Weird workaround that works:
I was continuing to play around with the browser, and used DevTools to inspect the DOM element and use it to Copy the JS Path.
Weirdly, after using Chrome Devtools to copy the JS Path, document.querySelector('#access-code') returned the correct element.
Screenshot of it returning the correct element: https://imgur.com/a/rSwCAxj
In both cases, the exact same search string is used for document.querySelector.
I believe that you cannot get proper value using document.querySelector('#access-code') because a website use frameset.
In the website there is frame with src to load content
<frame src="/internet-banking/Login/Login">
DOMContentLoading is executed when main document is loaded and not wait for frame content to be loaded.
First of all you need to have listener for load event.
window.addEventListener("load",function() {
...
});
And later on you cannot simply use document.querySelector('#access-code')
because input yuo want to get is inside frame. You will need to find a way to access frame content and than inside of it use simple querySelector.
So something like:
window.addEventListener("load",function() {
console.log(window.frames[0].document.querySelector('#access-code'));
});
BTW please see in: view-source:https://internet.ocbc.com/internet-banking/ looks like website is mostly rendered client-side.
I am attempting to add in a third party plugin to TinyMCE that is built to connect language-tool and TinyMCE. The plugin will load and work properly only after the second time the page is loaded. The plugin is properly created here
tinymce.PluginManager.add('languagetool', function(editor, url) {
and added to the TinyMCE plugin list here
config.plugins = 'languagetool link lists paste';
When loading the page the first time, I receive the following error.
Uncaught TypeError: Cannot set property 'onload' of null
TinyMCE does not load the editor box at all. After switching to a different page and back, the error no longer appears but the TinyMCE editor (with some plugin functionality) is now visible and is able to be used.
Without seeing running code it will be difficult for anyone to give you a specific thought on why this is happening. Any time I see:
Cannot set property 'xxxxxxx' of null
...this typically means that some code assumes a variable has a value when its null. For example I could try to execute:
tinymce.activeEditor.getContent();
...but if there is no active editor then tinymce.activeEditor is null and you can't execute the getContent() on null. In your scenario some part of the code is trying to run the onload method but the object on which that is being called is null.
You need to figure out what line of code is causing that and then figure out why a variable is null when it is expected to be something else.
I had a previous post related to this problem but I guess I was not clear enough or some other reason, I did not get a solution.
Old post here
I now have minimized the whole html to just demonstrate the problem and uploaded the html.
Here the link to the loaded HTML
There are two html files - main.html and sample.html. Main.html loads sample.html using jQuery.load(). There is a JavaScript inside the sample.html which query the width of a div and visibility of a div. Both queries gives wrong results. You can look at the debug console of the browser for the results returned. I have tried FF, IE and chrome and all gives the consistent wrong values. I guess I am not doing something correctly. What could be wrong here ?
Some guy points out that Firebug does display the source file and line for event handlers. I have a pseudo-class defined somewhere within 11 script files. Could I use Firebug to find out which file did I put it into? *
It's embarrassing when you write a code and you just can't find it while executing it...
* Pseudo-class is just a function that keeps it's namespace after execution. If I put it very simply...
To find the code you can simply use the search field at the top right of Firebug when you are at the Script panel.
Ensure you have checked the option Multiple Files within the search options, then type the name of your "pseudo-class". You can hit Enter multiple times to switch through the matches.
When you found the code, the name of the file is displayed within the panel toolbar. Hover it to get the full URL of the file as tooltip.
I have one page which have chat application,wall comments,uploading photos,videos on that page.All is working fine on mozilla firefox,chrome but does not work on IE7.It gives two error
jquery-1.4.4.min.js
HTML Parsing error.Unable to modify
the parent container element before
the child element is closed
(KB9278917).
Because of this error my rightside bar of this page is not seeing & chat application is also not working.
Please reply me as early as possible.
Thank you
This question discusses the error message you have listed as (2).
You're modifying document while it's being loaded (when browser hasn't "seen" closing tag for this element) . This causes very tricky situation in the parser and in IE it's not allowed.
Since you're using jQuery, you can probably avoid this by putting whatever code is causing this error in a function called once the page is loaded, using the jQuery.ready function:
<script>
jQuery.ready(function() {
// put your code here, instead of just inside <script> tags directly
});
</script>