Exception in thread main orgopenqaseleniumElementNotInteractableException Element could not be scrolled into view | Selenium Forum
N
Naina Posted on 08/05/2019

In Module 13, CNN_specific_links is throwing an error , when I am trying to select all the links in the selected box.

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: Element <a href="https://www.cnn.com/politics/live-news/barr-contempt-mueller-report/h_f677b79348a74773806928740abb438f"> could not be scrolled into view

Please let me know what should I do to fix this

 


A
Ashish Thakur Replied on 09/05/2019

paste your code here


N
Naina Replied on 13/05/2019

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class CNN_Specific_Links {

public static void main(String[] args) {
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "null");
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://cnn.com");

WebElement box = driver.findElement(By.xpath("//*[@id=\'homepage1-zone-1\']"));
List<WebElement> links = box.findElements(By.tagName("a"));
System.out.println("Total Links - "+links.size());

for(int i=0; i<links.size();i++) {
String text = links.get(i).getText();
System.out.println(text);
links.get(i).click();
System.out.println(driver.getTitle());
driver.get("http://cnn.com");
box = driver.findElement(By.xpath("//*[@id=\'homepage1-zone-1\']"));
links = box.findElements(By.tagName("a"));
System.out.println("---------------------------");
}

}

}


A
Ashish Thakur Replied on 17/05/2019

Its seems...Well you need to scroll to that element us js executor.


N
Naina Replied on 30/05/2019

Thanks, it is working