Phantom.js WebDriver.io Error: Issue with Syntax - DOM Exception 12

Currently conducting tests using webdriver.io and phantom.js. The first test works successfully, providing a list of elements:

return client
    .url(config.host)
    .waitForVisible('#myvenuelist', 2000)
    .click('#myvenuelist')
    .elements('li.venue')
    .then(function(venues)
    {
        // Ensure there is at least one venue
        // Can perform a scan before to check the size
        venues.value.length.should.be.at.least(venueList.length);
        done();
    });

However, moving on to the next test, it involves similar actions:

return client
    .url(config.host)
    .waitForVisible('#myvenuelist', 2000)
    .click('#myvenuelist')
    .waitForVisible("li.venue[data-id=" + allVenues[0].venue_id + "]", 5000)
    .click("li.venue[data-id=" + allVenues[0].venue_id + "] a[class='btn primary']")
    .waitForVisible('a[class="tab beacons"]', 2000)
    .click('a[class="tab beacons"]')
    .waitForVisible('a[class="tab beacons active"]', 2000)
    .elements("a[class='add-monitor btn primary']")
    .then(function(deviceList)
    {
        deviceList.value.length.should.be.at.least(1);
        done();
    });

After retrieving the deviceList object, attempting to access the array results in an error:

CommandError: Promise was fulfilled but got rejected with the following reason: Error: SyntaxError: DOM Exception 12 

This issue is perplexing. Despite finding reports of DOM Exception 12 errors, they do not seem relevant to my scenario, especially considering we are using Phantom.js version 1.9.8.

Answer №1

Here's a suggestion:

let venueId = allVenues[0].idVenue;

return client
    .url(config.host)
    .waitForVisible('#myvenuelist', 2000)
    .click('#myvenuelist')
    .waitForVisible(`li.location[data-id={venueId}]`, 5000)
    .click(`li.location[data-id={venueId}] a.button.primary`)
    .waitForVisible('a.tab.beacons', 2000)
    .click('a.tab.beacons')
    .waitForVisible('a.tab.beacons.active', 2000)
    .elements("a.add-monitor.btn.primary")
    .then( deviceList => deviceList.value.length.should.be.at.least(1) );

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

What is the best method for choosing a document from a Firebase based on its creation time?

Currently delving into Firebase as part of my project, struggling with setting queries in the Database. I've provided a breakdown of my Firebase database structure below: Looking to retrieve the most recently created document from the 'subscrip ...

How can data tables be generated using AJAX, JSON, HTML, and JS?

HTML: <table> <tr> <th>Student Name</th> <th>Student Grades</th> </tr> <tr> <td> <select name="dropdown" id= ...

Obtain the HTTP response status code within a middleware function

I am currently developing an application where I want to create a custom logging system for every request made. For each request, I want to log the timestamp, method, route, and the response code sent to the client. Here is the code I have at the moment: ...

Tips for choosing or unselecting a row within a Table utilizing the Data Grid Mui

Is it possible to implement row selection and deselection in Mui without using the checkboxSelection prop? I am looking for a way to achieve this functionality in @mui/x-data-grid when clicking on a row. Below is the code snippet from the Table Component ...

Applying onclick css changes to a specific duplicate div among several others?

Recently, I encountered a situation where I have multiple identical divs on a page. <div class="class" ng-click="example()"></div> With the use of Angular 1.6.4 and jQuery, these divs are styled with background color and border color. Now, w ...

Is it possible to create dynamic backgrounds using Twitter Bootstrap's responsiveness?

Is there a way to create a responsive image arrangement for backgrounds on a website? Imagine having different background images load based on various screen resolutions. Additionally, it would be advantageous to specify different behaviors such as having ...

What is the method to retrieve the current tab's URL using Selenium?

Things seem to be running smoothly, but every time I click on a new tab, I can't seem to extract the URL. I've tried using current_url, response.url, and getCurrentUrl without success. What am I overlooking? What would be the best approach to sol ...

What is the method for a JavaScript program to determine if a global property name has been defined according to the ECMA-262 standard

Imagine creating a function called checkIfEcmaGlobal which would return true for recognized names of ECMA-262 globals. $ node > checkIfEcmaGlobal('Array') true > checkIfEcmaGlobal('process') false What approach could be taken to ...

Save a JSON object from a URL into a JavaScript variable using jQuery

I am trying to figure out how to use the .getJSON() function to store a JSON object as a JavaScript variable. Can someone guide me through this process? var js = $.getJSON(url, function(data) {...} ); Is it necessary to include the function(data) { ...

Check if there are any child nodes before executing the RemoveChild JavaScript function to avoid any errors

function delete(){ let k = document.getElementsByClassName('row'); for(let i=0; i<k.length; i++) { if(k[i].hasChildNodes()){ k[i].removeChild(k[i].childNodes[2]); } } } <div id="table"> <div class="row"& ...

Mastering jQuery ajax in Google Chrome Extensions

I have developed a script to fetch data from an external server using JSONP request in jQuery. Please take a look at the code snippet below: $("#submit").click(function() { var state = $("#state").val(); var city = $("#city").val(); $.ajax({ ...

triggering a touchend event using jQuery Mobile

I'm currently utilizing jQuery Mobile in my project. Is there a way to terminate a gesture using jQuery Mobile? Let's say a user places their fingers on the screen and performs a drag - can I end this action programmatically with JavaScript, eve ...

The issue with Selenium's Java ``findElements`` method using class names is that it may not capture all

My code snippet can be seen below. List<WebElement> elements = driver.findElements(By.className("<this class name>")); System.out.println(elements.size()); Even though there are 50 elements with the specified class name on the page, only 40 ...

How to use JavaScript and regex to control the state of a disabled submit button

I have a challenge where I need to activate or deactivate a submission button in a form called btn-vote using JavaScript. The button will only be activated if one of the 10 radio buttons is selected. Additionally, if the person-10 radio button is chosen, t ...

What could be the source of the "Uncaught Error: write after end" error occurring in my test cases?

Below is the code I am working with: var Promise = require('bluebird'); Promise.longStackTraces(); var path = require('path'); var fs = Promise.promisifyAll(require('fs-extra')); var clone = require('nodegit').Clone ...

Easily toggle between various image source paths

In my current application, all HTML files have hardcoded relative image paths that point to a specific directory. For example: <img src="projectA/style/images/Preferences.png"/> Now, I am considering switching between two different project modes: & ...

Verifying the presence of an image via its URL may not be functional across all browsers

Hey folks, I'm working on a project that involves displaying an image along with other fields in a loop where the image source changes with each iteration. I also need to check if the image exists and set a default source if it doesn't. The code ...

What is the best way to send a JavaScript variable to a GraphQL query?

I'm struggling with making my super simple GraphQl query dynamic based on input. The query is straightforward, but I need to replace the hardcoded string of "3111" with a value from a variable called myString. How can I achieve this in JavaS ...

Inspect the render function in the 'RestApi' class

I encountered the following error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined ...

The array is devoid of any elements, despite having been efficiently mapped

I'm facing some challenges with the _.map function from underscore.js library (http://underscorejs.org). getCalories: function() { var encode = "1%20"; var calSource = "https://api.edamam.com/api/nutrition-data?app_id=#&app_key=#"; _.m ...