[Help] JS snippet to get project variable

fudge

Client
Регистрация
23.04.2022
Сообщения
14
Благодарностей
1
Баллы
3
Hello. I am trying to automate posting to google groups, and have gotten hung up in one spot. I am trying to get a variable so that I can paste the content on the variable using Javascript. I have not found another way that is possible. I will paste the snippet below that CahtGPT gave me. Similar snippets it gave me work but does not paste the content of the variable:

JavaScript:
string jsCode = $"document.getElementById('T2Ybvb0').textContent = '{instance.GetVariable("articleText")}';";
Please help me understand what is wrong. Thank you
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 183
Баллы
113
Hi, not really sure what are you trying to achieve. Why using javascript at the first place?
Use action designer for filling fields
 

fudge

Client
Регистрация
23.04.2022
Сообщения
14
Благодарностей
1
Баллы
3
Hi, not really sure what are you trying to achieve. Why using javascript at the first place?
Use action designer for filling fields
Hi Lokyis I hope you are well. I tried to use the action designer. That is what I normally do. It doesn’t work. Only JS executed in the active tab works to change the field. Then I have to use keyboard emulation to be able to click submit. Google groups is very hard to automate.

I am trying to get a variable (which is my article text from a file and paste it in using JavaScript. Is it possible?

Thank you
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 183
Баллы
113
Your initial code shows this:
document.getElementById with ID value of T2Ybvb0 which is identical to action designer
110869

Nevertheless, to say this Id - "T2Ybvb0" looks dynamically generated, which means it will fail next time you run it.

No argument Google is a complex page. You should expect nothing less from the biggest companies in the world :-)

Anyway, there is how to use javascript to fill some fields. You still have to adjust to work on your case, probably.

110870
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)