pythonselenium-webdriver

Statements must be separated by newlines or semicolons (Python selenium)


chrome = webdriver.Chrome()
chrome.get("https://www.hkexnews.hk/")

WebElement elements = 
chrome.findElement(By.xpath,
"//[@id='rbAfter2006']/ul")

enter image description here

WebElement elements = chrome.findElement(By.xpath,"//[@id='rbAfter2006']/ul")

The problem is on above line, it shows error "Statements must be separated by newlines or semicolons. I have no idea what is the problem assigning elements on it.


Solution

  • UPDATED

    Dynamic typing means that runtime objects (values) have a type, as opposed to static typing where variables have a type.

    Source

    Dynamic type checking is the process of verifying the type safety of a program at runtime.

    Source

    The error message you received does not really help to be honest but this meant that the IDE was not happy with:

    WebElement elements = chrome.findElement(By.xpath,"//[@id='rbAfter2006']/ul")

    but rather wants:

    elements = chrome.findElement(By.xpath, "//[@id='rbAfter2006']/ul")