I have a custom toolbar button created in accordance with the tutorial . The javascript code for the button is the following:
CustomButton = {
1: function () {
alert("Just testing")
},
}
And it works. When I click on this button, alert happens. I'm trying to make some changes, namely, fill input field on clicking this button, but this piece of code doesn't work:
CustomButton = {
1: function () {
document.getElementById("loginUserName").value = "aaaa";
},
}
The element with Id "loginUserName" exists on the page. I can easily fill it with Selenium WebDriver:
driver.findElement(By.id("loginUserName")).sendKeys(User).
So my question is why it doesn't work in Firefox extension?
Thanks, Racoon
Your toolbar button and the input field (assuming the latter is part of a web page) live in separate documents. But it's easy cross the boundary. Change your code to
gBrowser.contentDocument.getElementById("loginUserName").value = "aaaa";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.