How to make the light box active and click the login button | Selenium Forum
M
Posted on 03/02/2016
I have a question for you ,I was working on www.quikr.com site and when I tried to login there appears a light box I am able to close it and click the sign/register link in selenium webdriver but when the next light box opens I am unable to turn the focus on to it and click the login with facebook which opens up as a new window . So could you let me know how to approach this scenario , what I tried is 1.with xpath ,then id ,then class name then button ,then with set get window handles etc all but none worked .Could you help me.

Thanks
lilly.k

M
Replied on 03/02/2016

see if its in a frame.


M
Replied on 04/02/2016

Hi,

Well I just inspected through the (inspect element ) this is the code I am not sure if its in frame .

<button onclick="FBLoginReady(0);" class="face-login-btn"><div class="fa icon-facebook icon-facebook-logo"></div>
<span>Login with Facebook</span></button>


M
Replied on 04/02/2016

post relevant part of your code so i can try and run


M
Replied on 05/02/2016

Hi,

I am currently in another system I work in two and I found out that its a MODAL POPUP ,so how do you handle this in selenium webdriver .

Thank you
lilly.k


M
Replied on 05/02/2016

send a screen shot.


M
Replied on 07/02/2016

Hi ,

I have used the snipping tool so please see the attached document .


Thanks
lilly.k

Responsive image

M
Replied on 08/02/2016

you have to use actions class here.


M
Replied on 08/02/2016

Hi Ashish,


Please find the code here I have tried I dont know what mistake I am making but its not working .
[code:1joaje8r]import java.util.Iterator;
import java.util.Set;
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;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Actions;


public class Drivers {

public static void main(String[] args) {
FirefoxProfile prof = new FirefoxProfile();
prof.setEnableNativeEvents(true);


WebDriver driver=new FirefoxDriver();
Set<String> windowIds=driver.getWindowHandles();
System.out.println("Total window opened --> "+ windowIds.size());
Iterator<String> it = windowIds.iterator();
System.out.println(it.next());

driver.get("http://quikr.com");
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
driver.findElement(By.id("csclose")).click();
driver.findElement(By.xpath("//*[@id='logindiv']/ul/li[1]/a")).click();

WebElement rootNode=driver.findElement(By.xpath("//*[@id='signInSignUpHtml']/div"));
Actions act = new Actions (driver);
act.moveToElement(rootNode).build().perform();
driver.findElement(By.xpath("//*[@id='signInSignUpHtml']/div/div[2]/button")).click();


[/code:1joaje8r]



This is the code i am still not getting the mouse to click the facebook button that appears on the modal popup .

I am able to close the modal popup that appears first and and then click on the signin/Register link to move on to the next window or I am still not able to figure out what it is looks like a modal popup but not able to get the mouse to click that.

Let me know what mistake I am doing here . I will try it out .

Thank you
lilly.k


M
Replied on 08/02/2016

Try following code, it will work:

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class quickr {

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\Selenium Work\\Driver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://quikr.com");
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
driver.findElement(By.id("csclose")).click();
driver.findElement(By.xpath("//*[@id='logindiv']/ul/li[1]/a")).click();

WebElement rootNode=driver.findElement(By.xpath("//*[@id='signInSignUpHtml']/div/div[2]/button"));
Actions act = new Actions (driver);
act.click(rootNode).build().perform();


}

}


M
Replied on 08/02/2016

HI ,

First I thank you for your response .I appreciate it .Well I tried it but still not working this particular line says
Type mismatch cannot convert from void to webElement .

So I dont really know if you got this error so could you please check it .

WebElement rootNode=driver.findElement(By.xpath("//*[@id='signInSignUpHtml']/div/div[2]/button"));


Thank you
lilly.k


M
Replied on 08/02/2016

lilly i tried mohit's code and its working.


M
Replied on 09/02/2016

Hi lilly,

I am not sure why you are getting this error. It is working fine on my machine. Just try with latest selenium version.


M
Replied on 09/02/2016

Hi,

I tried it but still its not working I just tried with robot but need some help to complete it .Its a modal popup which selenium webdriver cannot handel and I guess we need to use robot . so if you can please check it out and let me know it will be really helpfull .

site : http://www.quikr.com

1. There is a first modal popup as soon as you go to that website some times it comes up sometimes it might not ,but it will surely comes when you run the code .
2. I am able to close it without any problem .

3.The next step is there is another modal popup that comes up this is were I am not able to bring the focus on and click the log in with face book.

could you please try and let me know which code works .

I did try using Actions and even enabling native elements in firefox that too dint work out .

let me know what works .

Thank you
lilly.k


M
Replied on 09/02/2016

Hi Mohit & Ashish,

I tried by copying it from the fourm it worked so thank you so much ,I appreciate your timely help .

Thank you
lilly.k


M
Replied on 19/02/2016

Hi Ashish,

I have a problem while compiling Ant I just need your help on this please . Please see the attached doc in which i have the error message.

Thank you
lilly.k

Responsive image

M
Replied on 24/02/2016

Hi lily,

Please send your project.


M
Replied on 24/02/2016

Hi Mohit,


I did fix the code and its working actually the few jars were on lib folder which Ant coudin't compile so I had to put them
together and it worked fine .Thank you so much.


Thank you
lilly.k