Is it possible that WebdriverIO is unable to retrieve the value for an input

Currently, I am in the process of automating tests specifically for a web application on Safari browser. However, I have encountered some challenges along the way. It appears that webdriverIO is not performing very well with Safari in my environment, which consists of: - wdio: v4.13.1 - node: v10.8.0

One issue I faced was trying to retrieve the value from an input field:

const value = browser.getValue('input.xxxxxxxxx')

This resulted in an exception:

The command 'GET /session/E5218F3F-7FE1-43D5-A231-A4B8CCB2C599/element/node-807A67A6-E0E8-4AD7-A505-9ED62ECD6FE6/property/value' was not found.
running safari
Error: The command 'GET /session/E5218F3F-7FE1-43D5-A231-A4B8CCB2C599/element/node-807A67A6-E0E8-4AD7-A505-9ED62ECD6FE6/property/value' was not found.
at elementIdProperty("node-807A67A6-E0E8-4AD7-A505-9ED62ECD6FE6", "value") - getValue.js:35:54

Interestingly, this works flawlessly when using Chrome. I even attempted a slightly unconventional method:

const value = browser.execute("document.querySelector('input.xxxxxxxx')")
console.log(value)
// yields:
{ sessionId: '40DD4190-CB6D-4188-962F-9059D96C0441',
value: null,
_status: 0 }

Unfortunately, no workaround has proven successful yet. Are there any suggestions to resolve this?

Furthermore, I noticed that performing a click action also presents difficulties in Safari. Despite the element being clearly visible, Safari complains of invisibility. My temporary solution for this is as follows:

browser.execute("document.querySelector('.popup-menu-items li).click()") 

In contrast, such workarounds are unnecessary in Chrome. Testing on Safari with webdriverIO has been quite challenging.

Answer №2

Yesterday, I found myself spending an excessive amount of time delving into this issue because I encountered the same error while using Safari with wdio v4.13.2

The error message was spot on - there indeed was no command available:

GET /session/:sessionId/element/:id/property/:name

However, what we actually needed to use is:

GET /session/:sessionId/element/:id/attribute/:name

I came across some documentation detailing the different calls that could be made here

Upon inspecting the getValue function in webdriverio, I noticed that it called a separate function named elementIdProperty, which sent a request to the URL

wd/hub/session/"sessionId"/element/"elementId"/property/value
mentioned previously. However, within the function, there was a condition stating that if it encountered an unknown command, it should instead call another function called elementIdAttribute that would make a request to the correct URL ending with /attribute/value. It seemed like Chrome recognized the response of an unknown command, but Safari did not. Manual requests showed distinct responses in each browser, making it a frustrating and challenging troubleshooting process.

To work around this issue, I opted to directly utilize the getAttribute function from webdriverio like this:

const value = browser.getAttribute(selector, 'value');

This temporary solution will suffice until a potential fix is implemented in a future version of webdriverio.

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

Using Parseint in a Vue.js method

For instance, let's say this.last is 5 and this.current is 60. I want the sum of this.last + this.current to be 65, not 605. I attempted using parseInt(this.last + this.current) but it did not work as expected. <button class="plus" @click="plus"&g ...

Solving Addition and Subtraction Errors in Javascript/Jquery

Upon running the script below, it aims to calculate the height of the browser, as well as the heights of both the header and footer, subtracting them from the initial browser height: var a = $(window).height(); alert (a); var b = $('#header').cs ...

Receiving array data in a Javascript function and storing it within a variable

Hello everyone, please take a look at my code below. I am attempting to pass PHP array values to a JavaScript function. When I run the script, I receive alerts for parameter0=1, parameter1=2, and parameter2=3 separately. What I am trying to achieve is to ...

Utilize model instance methods in Sails.js for enhanced functionality within views

Is there a way to retain model instance functions when passed to a view? For example, my User model has a method called fullName which combines first name, last name, and prefix. In the controller: User.find().done(function(err,users){ res.view({ ...

How to set the element in the render method in Backbone?

Currently, I am in the process of developing a web page utilizing BackboneJS. The structure of the HTML page consists of two divs acting as columns where each item is supposed to be displayed in either the first or second column. However, I am facing an is ...

Tips for sending the parent object through a jQuery.ajax success function

I'm currently working on a function that includes child functions and objects: //API load function var apiDataLoader = function () { // Set default settings this.apiSeason = '7924'; this.apiMatchDay = '30'; th ...

What is the process for executing the Selenium Chrome driver within a Docker container?

tl;dr Is there a way to set up Selenium with a headless Chrome Driver in a docker container? Question I have a starting image: FROM microsoft/aspnetcore-build:2 AS builder WORKDIR /source COPY . . RUN dotnet restore RUN dotnet build ENTRYPOINT ["dot ...

Attempting to extract a text string from a chunk of HTML code

My goal is to extract a text string (specifically, an article title) from a snippet of HTML code. The title in question reads "Journalist Allegedly Spied on Zoom Meetings of Rivals in Hilariously Dumb Ways." The challenge lies in the fact that the title d ...

I am unable to determine if I have already selected a List Item

My goal is to have a functionality where clicking on "Download Drivers" will open the list, and clicking again will close it. This should be achieved with onclick events only, no hover effects. Additionally, I want the list to remain open even if I click o ...

I'm looking for assistance on how to execute a render right after making a put or delete request

class ProductApp extends Component { constructor() { super(); this.state = { currentProduct: null, items: [], }; this.handleUpdateSubmit= this.handleUpdateSubmit.bind(this); } componentDidMount() { axios.get('h ...

Using Selenium's WebDriver Sampler in conjunction with JMeter in Internet Explorer - a winning combination?

Hey everyone! I'm looking to test my application using JMeters WebDriver Sampler. I've successfully tested it on Mozilla and Google Chrome, but when I tried testing it on Internet Explorer, I encountered the following error: java.lang.IllegalSta ...

Utilize javascript/jquery for transforming HTML table data to JSON

Whenever I click the "+" button, my table rows are dynamically generated. After populating the fields and clicking the submit button next to "+", the JSON data is displayed in the console, as shown in the image below. While generating the JSON data, I aim ...

What could be causing my images not to show up when I use string interpolation for src links in Vue.js?

I've encountered an issue while working on Vue.js where I'm struggling to render a couple of images from the local directory. What puzzles me is that this problem arises when using string interpolation, like in the code snippet below: <img :s ...

Unable to interact with popup UI button using Selenium automation

Hey there, I'm having some trouble clicking on a button within a popup ("klant aanpassen"). I've tried various options, including using ActionChains, but I just can't seem to get it to work. Here's my current script: driver.find_element ...

Best Practices for Utilizing NPM Modules with TypeScript

I am interested in developing an npm module using TypeScript. Can anyone suggest a best practice guide on how to start? Here are my questions: Node.js does not natively support TypeScript, so what is the recommended way to publish an npm module? Shoul ...

Transitioning Python with Selenium from a Mac computer to a Windows PC

What should be straight forward for me is proving to be quite challenging. Despite running perfectly on my Mac with an up-to-date OS and Python 2.7, the code I am trying to bring over to my PC (Windows 8, Python 2.7) for scheduling and automation is causin ...

Firefox and Internet Explorer do not support the functionality of HTML5 <audio> tags

My radio stream player code works perfectly on Chrome and iOS Safari, but I'm facing compatibility issues with Firefox and Internet Explorer 11. Here's a snippet from my index.php file: <script type="text/javascript" src="http://code.jquery. ...

Grab the source attribute of the <img> tag (identified by class) across numerous HTML pages

Here is an example: A website has the URL , where xxxx represents an integer between 1 and 1935. On each page, there may be an <img class="thumbnail" src="Images\Robots\{robotname}.png">. However, not all pages have th ...

How can CSS positioning be utilized to align lines accurately?

Recently, I created a basic jsbin to draw a line connecting two points. It doesn't rely on any drawing libraries; just plain JavaScript and jQuery. I managed to calculate the angle using code I found in this library. When dragging the circle at the ...

Socket.io is most effective when reconnecting

I am currently in the process of developing a React application that connects to a Node.js API and I am trying to integrate the Socket.io library. Following various online tutorials, my code now looks like this: API: import express from 'express&apo ...