2

I have a problem with switching frames in Selenium. I'm using Firefox Webdriver.

In the first step I'm switching to Masterpass_frame then I click on a button to force the frame to reload. Then I need to put values into the login form which is in MasterPass_wallet_frame.

I've tried switching to the MasterPass_wallet_frame by switchTo.defaultContent() and then switchTo.frame("MasterPass_wallet_frame") but nothing is happening.

Do you have any ideas how to do that? It's my first big problem in Selenium. I'm still learning.

This is the html code

<div id="MasterPass_container">
<iframe id="MasterPass_frame" frameborder="0" src="https://sandbox.masterpass.com/lightbox/version232/Switch/index.html?allowedCardTypes=master%2Camex%2Cdiners%2Cdiscover%2Cjcb%2Cmaestro%2Cvisa&allowedLoyaltyPrograms=&allowedShipToCountries=US%2CAU%2CBE%2CBR%2CCA%2CCN%2CFR%2CIL%2CIT%2CNL%2CRO%2CSG%2CES%2CSE%2CAE%2CGB&shippingLocationProfile=&callbackUrl=https%3A%2F%2Fsandbox.masterpass.com%2FCheckout%2FMerchantDemoCallback%3Fconsumer_key%3DNeqwj09Ay7dYCB0D38HwjrEbyAWQpsgbdKYdjPTtdbe4fe96!467a4c6c7341586a584d5a554766526a7154786a4b513d3d&flow=checkout&locale=en-US&merchantCheckoutId=a4a6w3nlg59yjh02zn7v21h030a78pon&requestedDataTypes=&requestToken=ca01084580335b3c432ffbc2743055108737284b&version=v6&pairingRequestToken=108f1df6326733182b551bdc045db70c483d1024&requireShippingDestination=true&clientOrigin=https%3A%2F%2Fsandbox.masterpass.com&targetOrigin=https%3A%2F%2Fsandbox.masterpass.com" allowtransparency="true" name="MasterPass_frame">
<!DOCTYPE html>
<html class="js canvas geolocation video audio localstorage sessionstorage texttrackapi track formvalidation fieldsetdisabled styleableinputrange no-details" lang="en-us">
<head>
<body id="iframe-body" class="switch-frame">
<div id="MasterPass_animation_overlay" class=""></div>
<div id="closeContainer">
<div id="headerPanel" style="display: block;">
<div id="topNotificationContainer" class="">
<div class="top-notification-overlay"></div>
<div id="mainPanel">
<div id="walletWindow" class="mp-frame">
<iframe id="MasterPass_wallet_frame" frameborder="0" height="590" width="690" style="height:100%;" allowtransparency="true" src="https://wallet.beta.upaid.pl/portfel?merchant_return_url=https%3A%2F%2Fsandbox.masterpass.com%2Flightbox%2Fversion232%2FSwitch%2Fcallback.html%3Foauth_token%3Dca01084580335b3c432ffbc2743055108737284b&flow=checkout&locale=en-PL&targetOrigin=https%3A%2F%2Fsandbox.masterpass.com&clientOrigin=https%3A%2F%2Fsandbox.masterpass.com&walletId=uPaidV6b&acceptable_cards=master%2Camex%2Cdiners%2Cdiscover%2Cjcb%2Cmaestro%2Cvisa&checkout_identifier=a4a6w3nlg59yjh02zn7v21h030a78pon&requestedDataTypes=&oauth_token=ca01084580335b3c432ffbc2743055108737284b&pairingRequestToken=108f1df6326733182b551bdc045db70c483d1024&checkout_version=6&merchant_name=andresTest638&auth_options=NO_3DS&cardinal_merchant_id=mcpaypass&amount=2500&currency=840&order_number=1450682352687&suppress_shipping_address=false&merchantSuppressSignup=false">
<!DOCTYPE html>
<html lang="en">
<head>
<body class="pl">
<div class="main-window">
<div id="sidebar-container">
<div class="main-layout-container ">
<div style="height: 100%;">
<div class="main-content login">
<form class="form-horizontal max-height" accept-charset="UTF-8" action="https://wallet.beta.upaid.pl/auth/login" method="POST">
<input type="hidden" value="ayF6G1K5HJvpmcx8ikaGCBgzjw3gvFuYyhCsdf7U" name="_token">
<input type="hidden" value="ayF6G1K5HJvpmcx8ikaGCBgzjw3gvFuYyhCsdf7U" name="_token">
<input id="loginType" type="hidden" value="WEB" name="loginType">
<div class="container-fluid max-height">
<header class="content-header">
<div class="modal fade languageModal" aria-hidden="true" aria-labelledby="myLanguageModal" role="dialog" tabindex="-1">
<div class="row wrapp wrappedd">
<div class="col-xs-1 col-sm-1 col-md-4">
<div class="wallet-logo"></div>
<div class="advertising">
<span id="sm-app-link" class="blued sm-blued link full-display" data-target=".downloadModal" data-toggle="modal">Pobierz aplikację Wallet</span>
<a id="app-link-mobile-large" class="blued sm-blued link" target="_blank" href="https://upaid.pl/app" style="display: none">Pobierz aplikację Wallet</a>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-md-offset-1">
<div class="row">
<div class="col-xs-12">
<h4 class="disnone">Wybierz sposób akceptacji płatności</h4>
<div class="disnone sign-in-buttons-container">
<div class="web">
<div class="form-group">
<div class="col-xs-12">
<input id="prefix" class="prefix-switch form-control" type="text" value="+48" name="prefix" data-target=".prefixModal" data-toggle="modal" readonly="readonly">
<input class="login-input form-control" type="text" name="login" placeholder="Adres e-mail lub numer telefonu">
</div>
<div class="col-xs-12 errors-red"> </div>
</div>
<div class="form-group">
</div>
<div class="mobile" style="display: none;">
<div class="forget-password col-xs-12">
</div>
</div>
<hr class="big-margin-hr">
<div class="row">
</div>
</div>
<footer class="main-footer">
</div>
</form>
<div id="safari-user-modal" class="modal fade" aria-hidden="true" aria-labelledby="safariInfo" role="dialog" tabindex="-1">
</div>
</div>
</div>
</div>
  • are you getting any exception ?? – QAMember Dec 21 '15 at 8:22
  • It seems you have nested frame, so first switch to MasterPass_frame , then switch to MasterPass_wallet_frame , Then you can find element. And to switch in to frame does not require switchto.defaultcontent. – Helping Hands Dec 21 '15 at 8:41
  • Hi, I changed the OS from Ubuntu to Windows and the problem has gone. On win everything works fine. – Pawlo Dec 22 '15 at 12:13
1

First you have to switch to MasterPass_frame and then MasterPass_wallet_frame

driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@id='MasterPass_frame']")));

driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@id='MasterPass_wallet_frame']")));

and then try finding elements of login form and insert values in it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.