Changing textContent in workday [duplicate]

I am currently working on a Rate my professor Chrome extension that displays professor ratings on the workday. However, I am having some problems for access the specific span element by using getElementsByClassName.

Here is my code:

courses = document.getElementsByClassName(‘gwt-InlineLabel WG5F WF4F’) console.log(courses.textContent)

1 Like

Hi there @infobrother4,

Welcome to our forum.

Could you give us more info such as a screenshot so other members can get a better idea of what you are dealing with? Thanks!

Please refer to the topic below as well :point_down:

The issue with your code is that getElementsByClassName returns a collection of elements, not a single element. Therefore, you need to access a specific element from this collection using an index, like courses[0], or loop through the collection. Additionally, textContent should be accessed from an individual element within the collection, not directly from the collection itself. Here’s how you can fix it:

javascript

Copy code

let courses = document.getElementsByClassName('gwt-InlineLabel WG5F WF4F');
for(let i = 0; i < courses.length; i++) {
    console.log(courses[i].textContent);
}

This will log the textContent of each element that matches the specified class names.

Hi there, :wave:

Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.

In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!

Thanks! :sunglasses:
Katalon Community team