Not able to scroll to bottom of T& C pop-up | Selenium Forum
M
Posted on 30/03/2016
I tried the code to scroll in the pop-up of T&c. once scrolling only , it will activated "i agree " radio button
URL:
http://www.hotwheelscollectors.com/red-line-club/2016-red-line-club-membership-classic-hwrlcclub16cl
steps:
1. click on "add to cart"
2. a new page will open .Sign in by giving username: tester3987
and pass:Testing01
3. same url will open again with a pop-up .
4. now scroll till the bottom of pop-up
5.Click on add to cart button

M
Replied on 30/03/2016

check if its in iframe.


M
Replied on 31/03/2016

No it's not in frame.


M
Replied on 31/03/2016

what is code you're using? java script executor.


M
Replied on 31/03/2016

Following is the code which I used:


package Test_case;

import java.util.Iterator;
import java.util.Set;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;

import WIndow_Handle.Handle;

import com.gargoylesoftware.htmlunit.javascript.host.Window;

import Browser.BrowserFactory;
import Excel_Handle.Xls_Reader;


public class Pop_up {
WebDriver driver;
@Test
public void po() throws InterruptedException
{


driver = BrowserFactory.StartBrowser("CHROME", "http://www.hotwheelscollectors.com/2016-red-line-club-membership-classic-hwrlcclub16cl?
catalogId=11551&storeId=10153&langId=-1&krypto=Lg%2FsxAvAfFEmONeOPPSBhUN838Vh4Ifzev0Jt
G1kKfAzF%2F1PbUkSlLdizXE1xJplsYyMZCgU41px%0AUCQz7x2bkcteLnmmzRKYMW5ZSVZf5N%2Fz9wn
rBNk1q19rWdvxP2AJbokWjggbWnMILPDQ2XiImCGH%0AIALv96ukqu7dvQJhC9fo3remzR1pzytUn9kzqeZ
9zfJoiMhpc4vJDTXqn%2Bsy1sh6sB9fQsKI15Cx%0ARUx64TihIhinf1eX%2FkJl08%2BdFNhCaUIcM%2BS5
9NzVAEv08rZXf%2FhjVpmWV43O6xd%2FraA881fc%2Ftfz%0A6pHIEQoJeTiSIlIKn06R83pZWB%2FIVX8
oE8hLLN1k79pGD%2BxV7%2FsFQTX8pGjQ0BFUx6gYk32IoeeK%0Ao3m04CPpfRiy4zBJ99mvjMnW3Xct8
BfAklJXYgg2ssXzRyPIZZfIu7m1miacEeFbJIaCBw6PMsx7%0A2brQjG94fciFFD3p4ZYqJSLOjvpZGKMAwqe
QmOBFVCTkOsOPLhD5DBdfcEIJNb%2F%2Ftcos0kqYiQBG%0A2Khh3JNc8C1aU3FwFzsKJUBVmuDdleTYs
7rpJdJ1YC5LKMuMX8tD8ycwvNekDed3zcmBAZnz%2F56N%0A5UvO%2BazJ3sfuCPc7vf2x9bER97K7hXy
%2B");
WebDriverWait wait = new WebDriverWait(driver, 40);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='WC_QuickInfo_Link_addtocart']")));
driver.findElement(By.xpath("//*[@id='WC_QuickInfo_Link_addtocart']")).click();

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='logEmail']")));

//Xls_Reader database1 = new Xls_Reader("D:\\Data.xlsx");

//String usernam= database1.getCellData("HWC", 1, 3);
driver.findElement(By.xpath("//input[@id='logEmail']")).sendKeys("tester3987");


//String Password =database1.getCellData("HWC", 2, 3);
driver.findElement(By.xpath("//input[@id='logPassword']")).sendKeys("Testing01");
driver.findElement(By.xpath("//*[@id='signIn']")).click();



Thread.sleep(1000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='termsA']/div/div[1]/div/div[1]/div[2]/h2[1]")));

WebElement element = driver.findElement(By.xpath("//*[@id='termsA']/div/div[1]/div/div[2]"));






Coordinates cor =((Locatable)element).getCoordinates();
cor.inViewPort();
}
}


M
Replied on 31/03/2016

have you tried java script executor?


M
Replied on 31/03/2016

Yes I even tried that..but nothing works out. Please help on it.as it's kind of urgent


M
Replied on 01/04/2016

i working on it.


M
Replied on 01/04/2016

try scrolling with actions class.


M
Replied on 01/04/2016

It's scrolling with my code. But thing is that it's not scrolling to the bottom of pop up ..and I tried action also. Can you please try this.


M
Replied on 01/04/2016

Actually I am also able to scroll. But not till bottom. And without scrolling, I agree button won't work. There should be a way right. Or its not possible to automate?


M
Replied on 02/04/2016

yeah try scroll with actions class it might work it uses different mechanism for scroll then java script executor.


M
Replied on 02/04/2016

I have tried it's not scrolling till the bottom. Please check its. It's kind of urgent.


M
Replied on 04/04/2016

i'm working on it.


M
Replied on 07/04/2016

here try like this

[code:2y89utqk]
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;

public class Pop_up {
WebDriver driver;

@Test
public void po() throws InterruptedException, AWTException {



driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.hotwheelscollectors.com/2016-red-line-club-membership-classic-hwrlcclub16cl?catalogId=11551&storeId=10153&langId=-1&krypto=Lg%2FsxAvAfFEmONeOPPSBhUN838Vh4Ifzev0JtG1kKfAzF%2F1PbUkSlLdizXE1xJplsYyMZCgU41px%0AUCQz7x2bkcteLnmmzRKYMW5ZSVZf5N%2Fz9wnrBNk1q19rWdvxP2AJbokWjggbWnMILPDQ2XiImCGH%0AIALv96ukqu7dvQJhC9fo3remzR1pzytUn9kzqeZ9zfJoiMhpc4vJDTXqn%2Bsy1sh6sB9fQsKI15Cx%0ARUx64TihIhinf1eX%2FkJl08%2BdFNhCaUIcM%2BS59NzVAEv08rZXf%2FhjVpmWV43O6xd%2FraA881fc%2Ftfz%0A6pHIEQoJeTiSIlIKn06R83pZWB%2FIVX8oE8hLLN1k79pGD%2BxV7%2FsFQTX8pGjQ0BFUx6gYk32IoeeK%0Ao3m04CPpfRiy4zBJ99mvjMnW3Xct8BfAklJXYgg2ssXzRyPIZZfIu7m1miacEeFbJIaCBw6PMsx7%0A2brQjG94fciFFD3p4ZYqJSLOjvpZGKMAwqeQmOBFVCTkOsOPLhD5DBdfcEIJNb%2F%2Ftcos0kqYiQBG%0A2Khh3JNc8C1aU3FwFzsKJUBVmuDdleTYs7rpJdJ1YC5LKMuMX8tD8ycwvNekDed3zcmBAZnz%2F56N%0A5UvO%2BazJ3sfuCPc7vf2x9bER97K7hXy%2B");
WebDriverWait wait = new WebDriverWait(driver, 40);
wait.until(ExpectedConditions.visibilityOfElementLocated(By
.xpath("//*[@id='WC_QuickInfo_Link_addtocart']")));
driver.findElement(By.xpath("//*[@id='WC_QuickInfo_Link_addtocart']"))
.click();

wait.until(ExpectedConditions.visibilityOfElementLocated(By
.xpath("//input[@id='logEmail']")));

// Xls_Reader database1 = new Xls_Reader("D:\\Data.xlsx");

// String usernam= database1.getCellData("HWC", 1, 3);
driver.findElement(By.xpath("//input[@id='logEmail']")).sendKeys(
"tester3987");

// String Password =database1.getCellData("HWC", 2, 3);
driver.findElement(By.xpath("//input[@id='logPassword']")).sendKeys(
"Testing01");
driver.findElement(By.xpath("//*[@id='signIn']")).click();

Thread.sleep(1000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By
.xpath("//*[@id='termsA']/div/div[1]/div/div[1]/div[2]/h2[1]")));

// WebElement element = driver.findElement(By
// .xpath("//*[@id='termsA']/div/div[1]/div/div[2]"));

// Coordinates cor = ((Locatable) element).getCoordinates();
// cor.inViewPort();

// WebElement ele = driver.findElement(By
// .xpath("//*[@id='termsA']/div/div[1]/div/div[1]/div[2]/div[1]/p"));
// ((JavascriptExecutor) driver).executeScript(
// "arguments[0].scrollIntoView()", ele);

WebElement dragger1 = driver.findElement(By.xpath("//div[@class='jspTrack']/div"));
WebElement checkbox = driver.findElement(By.id("agreementAccept"));
System.out.println(checkbox);
driver.findElement(By.xpath("//p[@class='newsTitle']")).click();;

Robot robot = new Robot();
while(checkbox.getAttribute("disabled").equals("true")){
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
checkbox.click();
}




}
}[/code:2y89utqk]


M
Replied on 12/04/2016

yes . this code is working well. thanks. it helped a lot