Error: selenium web driver java cannot locate tinyMCE

driver.switchTo().frame("tinymce_iframe");    
String script="var editor=tinyMCE.get('tinymce_textarea');";    
JavascriptExecutor js=(JavascriptExecutor) driver;    
js.executeScript(script);    

I'm encountering a WebDriverException while trying to run this javascript code, as it returns an error stating that tinyMCE is not defined.

<html>  
<script type="text/javascript" src="tinymce3.5.1/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>

      <script type="text/javascript">
       tinyMCE.init({
        theme : "advanced",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        mode : "exact",
        elements : "tinymce_textarea"
      });
     </script>  
      <body>

     <textarea cols="80" rows="10" id="tinymce_textarea" name="tinymce_textarea"> 

         &lt;h1&gt;<span id="1">Article</span> <span id="2">Title</span>&lt;/h1&gt;
         <p><span id="3">Here's</span> <span id="4">some</span> <span id="5">sample</span> <span id="6">text</span> <span id="7">Hello</span> <span id="8" >World.</span> </p>
           </textarea>
</body>
</html>

Answer №1

Not sure if you have found a solution to your issue yet. Here are some suggestions to troubleshoot the problem without using tinyMCE or Selenium.

It appears to be a timing issue related to the iframe loading. Instead of using a timer, consider implementing an event listener. Wrapping the init function seemed to work for me. I came across a helpful tip in this forum post:

tinyMCE.execCommand('mceRemoveEditor', false, 'editorId');
setTimeout(function() {
    tinyMCE.init(myconfig);
}, 3000);

Alternatively, if you can identify the proper editor element, try using setInterval():

var IntID = setInterval(function () { // Repeated check for Editor
    if (($('.tinymce_textarea').length) > 0) { // Editor element length
        tinyMCE.init({
            theme : "advanced",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            mode : "exact",
            elements : "tinymce_textarea"
        });
        clearInterval(IntID); // This will clear timer for editor check
    }
}, 10);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Testing if the App properly renders results in an error message: "No element found with the text: Profil"

I am struggling with testing Jest as I lack experience in this area. Specifically, I need to determine whether the App component is being rendered successfully. However, my test cases are failing. Upon checking the console log, I encountered the following ...

Is there a way to determine the bounding rectangle of a specific word within a paragraph when you only have its index?

I am currently developing a text-to-speech functionality for a react application that can emphasize the word being spoken by highlighting it with a background color. This feature closely resembles the layout of the Firefox reader view. However, my curren ...

Generating a Personalized XML Format Using Information from a Single MySQL Table Row by Row

If anyone can assist with this, I would greatly appreciate it: <warehouse> <frontbay> </frontbay> <bayrow> <bay> </bay> <bay> ...

Display the full price when no discount is available, but only reveal the discounted price when Vue.js is present

In my collection of objects, each item is structured like this: orders : [ { id: 1, image: require("./assets/imgs/product1.png"), originalPrice: 40, discountPrice: "", buyBtn: require(&q ...

I'm curious if anyone has successfully incorporated Selenium into their StoryTeller fixtures

Is there anyone who has successfully incorporated Selenium with StoryTeller fixtures? If so, what is the process for integrating them and how do they contribute to continuous integration? ...

Looking for a Spring3 CLIENT in Java for Restful service?

Having some trouble unmarshalling JAXB on the client side, as I am encountering null properties for the object. This is the method I'm using to unmarshal: URL url = new URL("http://localhost:9191/service/firstName/tony?format=xml"); Http ...

Is there a way to modify a specific key value in all embedded objects using Mongoose?

I'm currently working on a chat application and I'm facing a challenge with implementing the 'seen' functionality. I need to update all chat messages in the database by setting the 'seen' column to true. Here is the schema st ...

Troubleshooting issue with the spread operator and setState in React, Typescript, and Material-ui

I recently developed a custom Snackbar component in React with Material-ui and Typescript. While working on it, I encountered some confusion regarding the usage of spread operators and await functions. (Example available here: https://codesandbox.io/s/gift ...

Having trouble retrieving information from the local API in React-Native

Currently, I have a web application built using React and an API developed in Laravel. Now, I am planning to create a mobile app that will also utilize the same API. However, I'm encountering an issue where I cannot fetch data due to receiving the err ...

Tips for executing Cross-Origin-Requests from Firebase Hosting to an AWS Lambda function

Excuse me, I'm still new to web development. I have a basic single-page website hosted on Firebase hosting that retrieves some information from an AWS Lambda function (I didn't use Google Cloud because it didn't support outbound requests fo ...

Various settings in JQuery UI Slider

Does anyone know how to customize the steps in a jQuery UI slider? I want to set specific values as steps, like 0, 1200, 2000, 2200, and 3000. Any suggestions on how to achieve this? const rangeSliderInit = () => { const valueArray = [0, 400, 1000, 1 ...

Error: req.body or req.params.id is not defined in the current context (PUT and PATCH requests)

I'm experiencing an issue where both req.body and req.params.id are returning undefined even though I am using express.json() before the app.patch. I have tried changing the route to /:id, but that did not resolve the problem. Interestingly, it works ...

Tips for handling a multi-step form in React?

Below is the code snippet for the multistep form I have been working on: import clsx from 'clsx'; import React from 'react'; import PropTypes from 'prop-types'; import { makeStyles, withStyles } from '@material-ui/styles ...

I am hoping for the outcome to be directed to the homepage

I'm struggling to figure this out, as I am new to classic ASP and JavaScript. I hope someone can help me understand. I want to display the response.write on the main.asp (or the result) page, but each time I try, it redirects to pass.asp on a differen ...

Using Nuxtjs/Toast with personalized image emblems

Would it be possible to include an icon in a toast error message, or is there a need to install another module for this functionality? I am currently using vue and attempting to integrate a component as an icon, but so far without success. this.$toast.er ...

Passing onClick event to parent component during iteration in ReactJS

I am facing a challenge where I need to remove a row from a table upon a click event. I have managed to create an iteration and display a delete button, but I am struggling with passing the onClick event from the parent component to the child component in ...

Exploring the World of Infinite Scrolling with React.js and Material_ui

I am currently working on a project using react.js As part of this project, I need to implement a board with infinite scroll similar to Facebook I have a specific question regarding this implementation. When scrolling the board and loading more posts li ...

What is the best way to record and share a video with jquery and laravel?

Is there a way to grant users access to record videos within an application and then upload them after previewing? I've been able to successfully record and download a video, but now I'm unsure of how to proceed with uploading it to the server. ...

What could be causing my Angular.js application to malfunction on IE7?

I have developed an Angular.js application that is working well on most browsers, but I am now facing compatibility issues with IE 7 and above. I have tried different approaches such as adding id="ng-app", using xmlns:ng, manually bootstrapping angular wi ...

I'm having trouble getting my .click method to work with the <div id=menuButton>. Can anyone help me figure out why this is happening?

Here is the HTML code I created for a dropdown menu. Initially, in the CSS file, the menu is set to display: none; <!doctype html> <html> <head> <title>DropDown Menu</title> <link rel="stylesheet" href="normalize ...