I'm trying to scroll to a particular element on a page but before I do that I'm trying to set myelement to be a WebElement object, heres the code:
from selenium import webdriver
browser.get("http://www.agoda.com/the-coast-resort-koh-phangan/hotel/koh-phangan-th.html")
WebElement myelement = browser.findElement(By.id("next-page"));
But it comes back with the error:
WebElement myelement = browser.findElement(By.id("next-page"));
^
SyntaxError: invalid syntax
What am I missing?
Update: Ok looks like I was trying to write Java! as the first reply has stated, but then my question kind of changes since my actual code is:
from selenium import webdriver
from selenium.webdriver.common.by import By
browser = webdriver.Firefox()
browser.get("http://www.agoda.com/the-coast-resort-koh-phangan/hotel/koh-phangan-th.html")
browser.find_element_by_xpath("//a[@id='next-page']").click()
myelement = browser.find_element(By.id("next-page"));
((JavascriptExecutor) browser).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
browser.find_element_by_xpath("//a[@id='next-page']").click()
Which gives the error:
File "<ipython-input-22-bb983f3ceca8>", line 10
((JavascriptExecutor) browser).executeScript("arguments[0].scrollIntoView(true);", element);
^
SyntaxError: invalid syntax
Probably writing Java again, but how should this be amended?