1

I am performing Automation for a redbus application but I am finding the web elements using firebug and it will highlight the firefox browser but it doesn't work in a chrome browser.

Please review the following screenshots: Redbus website link

  • step 1 Open redbus application URL =https://www.redbus.in/
  • step 2 Click Accounts module
  • step 3 Click sign or signup link

My XPath is :

.//*[@id='g-signin2']//span[text()='Sign in with Google']

Chrome browser screenshot: Can not identify the webElement

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Possible duplicate of [How to handle iframe in Selenium WebDriver using java](https://stackoverflow.com/questions/9942928/how-to-handle-iframe-in-selenium-webdriver-using-java) – JeffC May 18 '18 at 13:21

4 Answers4

1

Google sign up link is in Iframe , in order to interact with elements which are inside the frame/iframe , you need to change the focus of your web driver to that particular frame.

How you can do that in your case :

driver.switchTo.frame("//iframe[@class='modalIframe']")  

Then you can interact with Sign in with Google.

WebElement signupButton = new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[contains(@id,'signed') and text()='Sign in with Google']")))  
signupButton.click();  

HTH !

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • Exception in thread "main" org.openqa.selenium.NoSuchFrameException: No frame element found by name or id //iframe[@class='modalIframe'] Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z' Driver info: driver.version: unknown org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:884) at testdemo.sapmletest.main(sapmletest.java:34) – praveenraj r May 21 '18 at 05:35
  • Use this Xpath for switching the focus : driver.switchTo.frame("//div[@class='modal']/descendant::iframe") , you might wanna use explicit wait too before switching , let me know for any further assistance. – cruisepandey May 21 '18 at 09:30
  • you can try with this code also : new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//div[@class='modal']/descendant::iframe"))); – cruisepandey May 21 '18 at 09:32
0

To identify and invoke click() on the element with text as Sign in with Google, as the element is within an . So you have to induce WebDriverWait for both the cases, once for the frame to be available and again for the desired element to be clickable and you can use the following solution :

new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='modalIframe' and @src='/account?pageName=Home&noReload=noReload']")));
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[@class='abcRioButtonContents']//span[normalize-space()='Sign in with Google']"))).click();
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
-1

It looks the login popup is available inside the iframe tag. First navigate to that particular frame as below and then add the sign in xpath step.

driver.switchTo().frame(0);
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Subburaj
  • 2,294
  • 3
  • 20
  • 37
  • 1
    This will not work because there are more than one `IFRAME` on the page and the OP wants is not the first one. – JeffC May 18 '18 at 13:20
-1

What You have here is modal frame, You should first switch on it, and the do actions on elements:

driver.switchTo().frame("modalIframe");

or maybe this:

driver.switchTo().activeElement()
Kovacic
  • 1,473
  • 6
  • 21
  • This will not work because the name of the `IFRAME` is not `modalIframe`... that's the `class`. – JeffC May 18 '18 at 13:20