JavascriptExecutor: Cannot read property 'removeAttribute' of null - javascript

I am using Javascript executor to remove readonly attribute but it is giving an error.
Cannot read property 'removeAttribute' of null.
I have seen different posts where people confirm that after removing AdBlock from Chrome it worked. I don't know what is AdBlock and how to remove it from Chrome Binary at runtime, so I tried Firefox (Gecko Driver) but it is also throwing the same error.
Code:
driver.get("http://jsfiddle.net/343Rb/");
runJS().executeScript("document.getElementById('myInput').removeAttribute('readonly')");
Browsers I tried:
Chrome Binary latest, Firefox (GeckoDriver latest) on Windows 7
Links I went through:
TypeError: Cannot read property "removeAttribute" of null
Cannot read property 'removeAttribute' of null: Cant find source of it
Cannot read property *0* of null
Few posts above are purely JS based so I believe is the reason they are not replying to me.
I am using Selenium 3.0, Windows 7, Firefox, Chrome, Java, Testng

The problem is that the element you want is inside an <iframe>. You need to switch to it before querying for your element:
driver.switchTo().frame('result');
Or:
driver.switchTo().frame(driver.findElement(By.name('result')));

Related

Ag-Grid: "paste from clipboard" not working in Firefox

I'm struggling to make sense of the Clipboard feature of Ag-Grid. Currently, when trying to use it in Firefox (via any of the examples on the linked page), I'm getting the same error:
Uncaught TypeError: navigator.clipboard.readText is not a function
pasteFromClipboard https://www.ag-grid.com/archive/25.0.0/dev/#ag-grid-enterprise/all-modules/dist/ag-grid-enterprise.js:80812
onCtrlAndV https://www.ag-grid.com/archive/25.0.0/dev/#ag-grid-enterprise/all-modules/dist/ag-grid-enterprise.js:31893
doGridOperations https://www.ag-grid.com/archive/25.0.0/dev/#ag-grid-enterprise/all-modules/dist/ag-grid-enterprise.js:31758
processKeyboardEvent https://www.ag-grid.com/archive/25.0.0/dev/#ag-grid-enterprise/all-modules/dist/ag-grid-enterprise.js:31720
According to MDN, this method is indeed unavailable to the ordinary pages in Firefox - only to the extensions. Is there any known workaround for this issue?

onmozfullscreenchange warning in Firefox (not using react)

I keep getting this error in Firefox console.
onmozfullscreenchange is deprecated. editresume.js:411:4
onmozfullscreenerror is deprecated. editresume.js:411:4
Ignoring get or set of property that has [LenientThis] because the “this” object is incorrect.
If I go to my code file, for that line number, this is what I have
tempbutton.setAttributeNode(attid);
and, I am not using onmozfullscreenchange or onmozfullscreenerror anywhere.
Why am I getting this? It is also triggers a debugger exception for some reason, at that line number.
Note : I dont get a similar error/warning/breakpoint trigger on Chrome. So, its Firefox only.
Firefox version - 70.0
Chrome version - 77.0.X
This message may appear when logging the window or document objects and extending the resulting message in the Console.
It's because these getters are configured to warn about this deprecation so that developers can update their code accordingly.
However, this deprecation notice doesn't look at what tried to get it, so when the Console itself tries to get the value of these properties, it will also trigger the warning notification.
But your debugger exception certainly comes from somewhere else.

Object does not support this property or method IE8 error

I am running one application which is loading properly in all browsers except and keep getting "Object does not support this property or method" error. I am not sure which part to share here as i myself don't know which part is generating the error. Can anybody help me out with the area to look out for .

What's up with document.domConfig on Firefox?

I was iterating over properties of document when I ran into an interesting phenomena in Firefox, document claims to support the property domConfig although MDC says it isn't implemented but when I try to retrieve the property I get an exception:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOM3Document.domConfig]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: javascript:alert(typeof(document.domConfig)) :: :: line 1" data: no]
The following shows the behaviour, both Chrome and IE are consistent (I haven't checked Opera) in saying that domConfig is not a property of window but Firefox claims it is but can't retrieve it (copy paste into URL field since I can't get markdown to give a link).
/* true in FF, false in other browsers */
javascript:alert("domConfig" in document)
/* exception in FF, 'undefined' in other browsers */
javascript:alert(typeof(document.domConfig))
What's going on here?
Pointy's right, domConfig is exposed in an interface (DOM Level 3 Core Document - in Mozilla's source it's called nsIDOM3Document), but is not implemented (see nsDocument::GetDomConfig()). typeof works by first getting the value, then determining its type (and not from the interface definition), so it's not surprising typeof document.domConfig throws an exception.
As for why it's been done this way, the bug this code was added in doesn't have any discussion about that, so we can only guess.
My guess is that for specifications Mozilla intended to implement it made sense to finalize ("freeze" in Mozilla's terms) the interfaces, so that they could be used from binary code without further modifications after new properties/methods of the interface got implemented. And it didn't seem to matter much one way or another.
If you're interested in hearing from the developers, you could ask in mozilla.dev.tech.dom or mozilla.dev.platform.

Google Chrome JavaScript error - cannot call method 'join' of null

I started to test my web site on google chrome and
'cannot call method 'join' of null'
appears when doing this:
var sChoices = oQuestion.aChoiceRand.join("");
In IE and FF works well. What I'm trying to do with this code is to join all the aChoiceRand array elements in a string without any separators. How can I solve this?
The problem's cause must be earlier, when oQuestion.aChoiceRand gets assigned: you think it's assigned to an array (and apparently IE and FF agree with you), Chrome is telling you that it's null instead. We can't really help without seeing the code that's supposed to assign oQuestion.aChoiceRand its value...

Categories