0

So i have this little script:

var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('firefox').build();
driver.get('https://www.youtube.com/?hl=lt&gl=LT');
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElement(By.className("load-more-text']"));
js.executeScript("arguments[0].scrollIntoView();", element);

it supposed to open firefox go to youtube and scroll to bottom of the screen where the load more button is. But it throws syntax error.

1 Answer 1

1

You should try to change this line

WebElement element = driver.findElement(By.class("load-more=text']"));

as

WebElement element = driver.findElement(By.className("load-more-text"));

because class name load-more=text'] more likely to be load-more-text and AFAIK there is no By.class, but By.className

Sign up to request clarification or add additional context in comments.

4 Comments

sorry for those typos i changed hem but still get same error console underlines those js letters at 3rd line of code
You mean this line JavascriptExecutor js = (JavascriptExecutor) driver;?
if you made copy/paste of this line from net, try to retype it manually as sometimes it contains some hidden characters
i rewrited all script dont understand whats wrong :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.