How to assign webelement to string with javascript Executor

33 views
Skip to first unread message

sreedeviv...@gmail.com

unread,
Jul 11, 2018, 7:25:28 AM7/11/18
to Selenium Users

my id is hidden,how to assign webelement to string with javascript Executor

i have to perform below 2 operation with javascript executor:

String cartCountSearchTab = driver.findElement(By.id(("")).getText().replaceAll(" ", "");
int cartCountTab = Integer.parseInt(cartCountSearchTab);

Brenda Granados

unread,
Jul 12, 2018, 1:32:38 PM7/12/18
to Selenium Users
I'm a little unsure what you mean by the id is hidden. But if you do know it, you can try:
"document.getElementById('yourId')" in the JavaScript executor.execute call. You might try looking for that as a search term on the web, for more examples.
Reply all
Reply to author
Forward
0 new messages