I want to perform horizontal scroll using on this site
1) First reduce the browser size until you will see table scroll bar.
I have done with following code snippet, but it didn't work for me well.
driver.get("https://weather.com/en-IN/weather/5day/l/USID0011:1:US");
Dimension d = new Dimension(521,628);
driver.manage().window().setSize(d);
driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
My code is working well till now, but my execution is getting stopped from here.
I have try this scrolling issue with Action class but, same issue is getting replicated.
Actions act = new Actions(driver);
WebElement horizontal_scroll = driver.findElement(By.xpath("//div[@id='twc-scrollabe']/table"));
act.clickAndHold(horizontal_scroll).moveByOffset(40, 0).release().perform();
I have try with this below method also, but same issue is getting replicated.
WebElement horizontal_scroll = driver.findElement(By.xpath("//div[@id='twc-scrollabe']/table"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript(driver.execute_script("arguments[0].scrollIntoView()", horizontal_scroll));
In my application, I can not go with this method because there no style attribute is available inside table tag.
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById(''twc-scrollabe').setAttribute('style', 'position: relative; top: 0px; left: -658px; width: 1461px;')");
Can anyone help me on this issue?
Your help must be appreciated.
Best Regards,
Jainish Kapadia
//div[@id='twc-scrollable']/tablepoints at the scroller. If you have some specific element you should scroll towards, like a table cell, then you should find the cell andscrollIntoView()on it. NOT the table itself, since that is presumably already in view.scrollIntoViewto the lastthelement of the table...<table>element and act as if it's a scroll bar, which gets you this error.