first of all i wanted to say that im quite new to python and selenium in particular.
Me and a co-worker are trying to automate a web app to sort payments for us.
everything works up to the part where a pop window appears.This pop up basically its a credit card form.
The Issue is:
You can only interact with the fields, the two buttons and you can close it using the "X".
you cant inspect with developer tools, and i cant download any other programs for that because its
a work computer.
the things i found so far are the link as you can see in the address bar, and i was able to inspect it with the developer tools 'Network' tab.
here is the code that is in the window:
<html>
<head>
<title> ÷ìéèú ôøèé àùøàé </title>
</head>
<body>
<BR>
<iframe id="iFrame" width="100%" height="100%" src="" frameborder="0" ></iframe>
<script Language="JavaScript">
if (typeof(window.dialogArguments)!="undefined") document.getElementById('iFrame').src = window.dialogArguments;
</script>
</body>
</html>
the following is the code which sits inside the page itself (the input fields etc.):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<script src="merchantPages/WebSources/js/HE.js"></script>
<script src="merchantPages/leaseacar/js/main.js"></script>
<script src="merchantPages/leaseacar/js/tafnitTrack2.js"></script>
<link href="merchantPages/WebSources/css/main.rtl.css" rel="stylesheet" type="text/css" />
<title>דף תשלום מאובטח</title>
</head>
<body onload="resetForm();">
<!-- DISPLAY TRANSACTION INFORMATION -->
<div id="main_frame" align="center">
<div id="main">
<div id="page_title"><img id="ssl_logo" src="merchantPages/WebSources/images/ssl.png" alt="" title=""/><h1>דף תשלום מאובטח</h1></div>
<div id="logo"><img src="merchantPages/leaseacar/images/eTafnit.gif" alt="" title="" width="87" height="118"/></div>
<div class="sep"></div>
<div id="page_desc">
<em>עמוד זה הינו עמוד התשלום עבור העסקה שביצעת באתר.<br />תשלום בעבור ההזמנה יבוצע רק לאחר בחירה בכפתור "שליחה" שבתחתית המסך.<br />אנא אשר תחילה כי כל הפרטים בדף זה נכונים והזן את פרטי כרטיס האשראי כנדרש.</em>
</div>
<form id="creditForm" onsubmit="return formValidator(10);" method="POST" action="ProcessCreditCard">
<input type="hidden" name="txId" value="0ce8b10c-2550-4293-ac6b-fee0b61c5b80"/>
<input type="hidden" name="lang" value="HE"/>
<input type="hidden" name="last4d" value="" autocomplete="off" />
<input type="hidden" name="cavv" value="" autocomplete="off" />
<input type="hidden" name="eci" value="" autocomplete="off" />
<input type="hidden" name="transactionCode" value="Phone" autocomplete="off" />
<input type="hidden" name="expMonth" value="10" autocomplete="off" />
<input type="hidden" name="expYear" value="24" autocomplete="off" />
<input type="hidden" name="personalId" value="" autocomplete="off" />
<input type="hidden" name="userData1" value=""/>
<input type="hidden" name="userData2" value=""/>
<input type="hidden" name="userData3" value=""/>
<input type="hidden" name="userData4" value=""/>
<input type="hidden" name="userData5" value=""/>
<input type="hidden" name="userData6" value=""/>
<input type="hidden" name="userData7" value=""/>
<input type="hidden" name="userData8" value=""/>
<input type="hidden" name="userData9" value=""/>
<input type="hidden" name="userData10" value=""/>
<table class="data_tbl">
<thead>
<td colspan="4" class="td_style_1">הזנת פרטי כרטיס אשראי לתשלום</td>
</thead>
<tr>
<td class="td_style_fieldName">Card Number:</td>
<td><input type="text" id="cardNumber" name="cardNumber" maxlength="19"
style="width: 160px;" autocomplete="off" onchange="validateCardNumber();"/></td>
<td class="td_style_invalidField" id="invalidCardNumber"> </td>
</tr>
<tr>
<td class="td_style_fieldName">CVV:</td>
<td><input type="text" name="cvv" id="cvv" maxlength="4" style="width: 50px;" autocomplete="off" onchange="validateCvv();"/> <img src="merchantPages/WebSources/images/qm.png" onmouseover="showHideCVVhelp();" onmouseout="showHideCVVhelp();" style="cursor:pointer;"/><div id="CVVhelp" style="display: none; position: absolute; border: 1px #cccccc solid; padding: 10px; background: white;"><img src="merchantPages/WebSources/images/cvv.jpg" /></div></td>
<td class="td_style_invalidField" id="invalidCvv"> </td>
</tr>
<tr>
<td class="td_style_fieldName">Track2:</td>
<td><input type="password" name="track2" id="track2" value="" autocomplete="off" onchange="tafnitValidateTrack2();"/></td>
<td class="td_style_invalidField" id="invalidTrack2"> </td>
</tr>
</table>
<div id="form_buttons"><input type="submit" id="submitBtn" value="שליחה" /> | <input id="resetBtn" type="reset" value="ניקוי" /></div>
</form>
</div>
<br />
<img src="merchantPages/WebSources/images/rapidssl.gif" alt="" title=""/>
</div>
</body>
</html>
if someone could give me some advice on how could i target the window so i can close, or if its even possible.
this is what i got so far:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
#IMPORTS!-------------------------------------
usr = "***"
pwd = "***"
#app.
driver = webdriver.Ie(executable_path='C:/Users/natbag/Desktop/proj/IEDriverServer.exe')
driver.get('http://111.10.10.10/MENU1/LOGIN7.CSP')
driver.implicitly_wait(10)
username_box = driver.find_element_by_id('Username')
username_box.clear()
username_box.send_keys(usr)
password_box = driver.find_element_by_id('Password')
password_box.send_keys(pwd)
login_btn = driver.find_element_by_xpath('//input[#type="submit"]').click()
#------------------------End of Login ------------------------------------
#update contract page ----------
upd_con = driver.find_element_by_partial_link_text('עדכון חוזה').click()
#input latest Contract (F7) ----
input_con = driver.find_element_by_id('HOZ').send_keys(Keys.F7)
#goto receipts --------
receipts_btn = driver.find_element_by_xpath('//input[#name="BKBL"]').click()
Alert(driver).accept()
#input employee name ----- F7 for now later can be changed for custom number -----
work_name = driver.find_element_by_xpath('//input[#name="OVED"]').send_keys(Keys.F7)
#Receipts after username --------------------
receipts_btkn = driver.find_element_by_xpath('//input[#name="BTKBL"]').click()
#2 Seconds SLEEP IS MANDATORY!!! ----
#select Credit Card by Last Value (F7) can be changed to custom value
cc = driver.find_element_by_id('KSM').send_keys(Keys.F7)
#-------------- CANT INTERACT WITH CC WINDOW -----------------
WebDriverWait(driver, 5).until(EC.frame_to_be_available_and_switch_to_it((driver.find_element_by_xpath('//iframe[#id"iFrame"]'))))
#WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[#type='text'] and [#id='cvv']"))).click()
sorry for the long post,
thanks in advance
Well i figured it out using pyautogui.
tnx everyone
I want to login to https://student.amizone.net using Requests library in python but I am getting the error ERROR for site owner: Invalid domain for site key this error does not show when I open website through browser. How can I login?
this is my python code, that I have tried:
import requests
login_data = {
'_UserName': 'username',
'_Password': 'password'
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
}
with requests.Session() as s:
url = 'https://student.amizone.net'
r1 = s.get(url, headers=headers)
r2 = s.post(url, data=login_data, headers = headers)
print(r1.text)
I have also tried: r1 = s.get(url, headers=headers, auth=HTTPBasicAuth('user','pass')) but got the same result(didn't login)
this is the response r1.text that i'm getting:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Amizone</title>
<link href="/Content/bootstrap.css" rel="stylesheet">
<link href="/Content/font-awesome.min.css" rel="stylesheet" />
<link href="/login-files/main.css" rel="stylesheet" />
<link href="/Content/owl.carousel.css" rel="stylesheet" />
<style>
#media(min-width:991px){
.login100-form {
left:420px;
}
.login100-pic {
right:420px;
}
}
</style>
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<div class="logo-section">
<img src="/login-files/amizone-logo.png" />
</div>
<div class="widget-box login-box visible login100-form" id="login-box">
<span class="login100-form-title">
LOGIN <small> Student | Parent </small><br clear="all" />
<span>
<a href="https://amizone.net/adminamizone/index.aspx">
<b style="color:blue;">
Click here for admin login
</b>
</a>
</span>
</span>
<form action="/Login/Login" class=" validate-form" id="loginform" method="post" name="loginform"> <div class="wrap-input100 validate-input" data-validate="User Name is required">
<input autocomplete="off" class=" input100" data-val="true" data-val-required="User Name is required !!" name="_UserName" placeholder="User Name" type="text" value="" />
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-user" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<input autocomplete="off" class=" input100" data-val="true" data-val-length="Must be between 5 and 20 characters" data-val-length-max="20" data-val-length-min="5" data-val-required="Password is required !!" name="_Password" placeholder="Password" type="password" />
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-lock" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100">
</div>
<div class="container-login100-form-btn">
<button type="submit" class="login100-form-btn">Login</button>
</div>
<div class="text-center p-t-12 fg-password">
<span class="txt1">
Forgot
</span>
<a href="#" class="txt2" data-target="#forgot-box">
Username / Password?
</a>
</div>
</form> </div>
<div class="widget-box forgot-box login100-form" id="forgot-box">
<span class="login100-form-title">
Password Recovery
</span>
<form action="/Login/ForgotPassword" class=" validate-form" id="ForgetForm" method="post" name="ForgetForm"><input name="__RequestVerificationToken" type="hidden" value="CIu-qUEXGRgcyZkrrLhEbz-8rIxUM2Vj8bZTqFeP96KoaLdnAX_COKuwy-6vm_HHZTdZd8dUCylFh8_Y5aWNJiJSD0RlGZgSz3i6yMPvWSQ1" /> <div class="wrap-input100 validate-input" data-validate="User Name is required">
<input autocomplete="off" class="input100" data-val="true" data-val-required="User Name is required !!" name="_UserName" placeholder="User Name" type="text" value="" />
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-user" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100">
<div class="g-recaptcha" data-sitekey="6LfVOEcUAAAAAFa_lQg8WJ-e_5qYNDnlmxSXL05S"></div>
</div>
<div class="container-login100-form-btn">
<button type="submit" class="login100-form-btn">Get Password</button>
</div>
<div class="text-center p-t-12 fg-password">
<span class="txt1">
Back
</span>
<a href="#" class="txt2" data-target="#login-box">
Login
</a>
</div>
</form> </div>
<div class="login100-pic">
<div id="owl-demo" class="owl-carousel owl-theme">
<div class="item">
<a href="https://www.amity.edu/asfd/" target="_blank">
<img src='/login-files/amizonedrama.jpg' data-zoom-image='/login-files/amizonedrama.jpg'>
</a>
</div>
<div class="item">
<a href="https://amity.edu/amimun/" target="_blank">
<img src='/login-files/AMIMUN20.jpg' data-zoom-image='/login-files/AMIMUN20.jpg'>
</a>
</div>
<div class="item">
<a href="http://amityfinishingschool.com" target="_blank">
<img src='/login-files/QSRanking.jpg' data-zoom-image='/login-files/QSRanking.jpg'>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="/Scripts/owl.carousel.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="/login-files/jquery.elevatezoom.js"></script>
<script src="/login-files/main.js"></script>
<!-- include the style -->
<link rel="stylesheet" href="/Content/alertifyjs/alertify.min.css" />
<!-- include a theme -->
<link rel="stylesheet" href="/Content/alertifyjs/themes/default.min.css" />
<script src="/Scripts/alertify.js"></script>
<script type="text/javascript">
$("#owl-demo").owlCarousel({
navigation: false, // Show next and prev buttons
slideSpeed: 300,
paginationSpeed: 400,
singleItem: true,
autoPlay: 3000,
});
jQuery(function ($) {
$(document).on('click', '.fg-password a[data-target]', function (e) {
e.preventDefault();
var target = $(this).data('target');
$('.widget-box.visible').removeClass('visible');//hide others
$(target).addClass('visible');//show target
});
});
</script>
<script>
$(".rank-image").elevateZoom({ constrainType: "height", constrainSize: 274, zoomType: "lens", lensShape: "round", lensSize: 100, containLensZoom: true, gallery: 'gallery_01', cursor: 'pointer', galleryActiveClass: "active" });
</script>
</body>
</html>
r2.text is the same.
this is how the site looks in the browser, it shows no reCAPTCHA:
I want to click an frame source's radio button, but it doesn't work. I think, frame source doesn't have iframe id or name.
my code is this.
import time
from selenium import webdriver
Url='https://www.youtube.com/watch?v=eIStvhR347g'
driver = webdriver.Firefox()
driver.get('https://video-download.online')
driver.find_element_by_id("link").send_keys(Url)
driver.find_element_by_id("submit").click()
time.sleep(5)
#this part is problems... don't working
driver.switch_to_frame(driver.find_element_by_xpath('//iframe'))
driver.find_elements_by_xpath("//*[#type='radio']")[0].click()
driver.find_element_by_xpath(".//button[contains(text(),'Proceed')]").click()
html source is this.
<html>
<head>
<meta charset="utf-8"/>
...
<script>
if (top.location !== location) {
top.location = self.location;
}
if (location.host !== 'video-download.online' && location.host !== 'beta.video-download.online') {
eval("location.href=''+'//'+'video-download.online';");
}
</script>
<meta name="msapplication-tap-highlight" content="no"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta name="author" content="Luca Steeb"/>
<meta name="theme-color" content="#008679"/>
<meta name="description" content="Download from this uploaded.net premium link generator with highspeed. For free."/>
<meta property="og:title" content="Video-Download.online"/>
<meta property="og:description" content="Download videos, mp3s and playlists from 1979 sites - for free."/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="video-download.online"/>
<meta property="fb:page_id" content="1143492155680932"/>
<meta property="og:image" content="//video-download.online/img/logo.jpg"/>
<link rel="shortcut icon" href="/favicon.ico?1"/>
<link rel="icon" sizes="192x192" href="/img/logo_small.jpg"/>
<link rel="apple-touch-icon" href="/img/apple-touch-icon.png"/>
<link rel="search" type="application/opensearchdescription+xml" title="Video-Download.online" href="/opensearch.xml"/>
<title>
Online Video Download
</title>
<meta name="robots" content="noindex, nofollow"/>
<link rel="stylesheet" href="/css/bt.css"/>
<link rel="stylesheet" href="/css/style.css"/>
<noscript><iframe height=0 src="//www.googletagmanager.com/ns.html?id=GTM-TWMNRP"style=display:none;visibility:hidden width=0></iframe></noscript><script>!function(e,t,a,n,r){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var g=t.getElementsByTagName(a)[0],m=t.createElement(a),s="dataLayer"!=n?"&l="+n:"";m.async=!0,m.src="//www.googletagmanager.com/gtm.js?id="+r+s,g.parentNode.insertBefore(m,g)}(window,document,"script","dataLayer","GTM-TWMNRP")</script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create','UA-54289597-5','auto');ga('send','pageview');</script>
<script>function send(action) { ga('send', 'event', 'button', 'click', 'download-' + action) }</script>
<script async src="/js/jquery.js"></script>
<script>function _(n,i){i?window[n]?i():setTimeout(function(){_(n,i)},100):window.jQuery?window.jQuery(document).ready(function(){n(window.jQuery)}):setTimeout(function(){_(n)},100)}</script>
</head>
<body>
<header class="navbar navbar-info navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle no-waves" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="nav-brand">
<a class="navbar-brand" href="/">
<img class="logo" src="/img/logo.svg" alt=""/>
<div class="parent">
Video-Download<small>.online</small>
<br/>
<span class="small-text">1979 sites officially supported</span>
<span id="changelog"></span>
</div>
<span class="clear"></span>
</a>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<div class="social">
<div class="fb-like fb-nav" data-href="https://www.facebook.com/VideoDownload.online"
data-layout="button_count" data-action="like" data-show-faces="false" data-share="true">
</div>
</div>
<div class="social-close" title="Hide all social buttons">×</div>
<li class=" ">
<a href="/">
Home
</a>
</li>
<li class=" ">
<a href="/sites">
Sites
</a>
</li>
<li class=" ">
<a href="/contact">
Contact
</a>
</li>
<!--html.navItem('/app', 'Mobile App')-->
</ul>
</div>
</div>
</header>
<noscript class="fixed">
<div class="container">Please enable javascript. Video Download and almost all other sites don't work properly
without it.
</div>
</noscript>
<div id="alert" class="alert alert-fixed alert-dismissible m-t-15 hidden">
<div class="container relative">
<span id="alertText"></span>
<span class="close-alert" onclick="_(function() { $('#alert').remove();$('body').removeClass('alert-showing') })" title="close">×</span>
</div>
</div>
<main class="container">
<div>
<h1>Legal</h1>
<div style="width: 50%;" class="center">
</div>
</main>
<script src="/sweetalert/sweetalert.js"></script>
<link rel="stylesheet" href="/sweetalert/sweetalert.css">
<script src="/waves/waves.min.js"></script>
<script src="/js/dropdown.js"></script>
<script src="/js/main.js"></script>
<script src="/js/bootstrap.js"></script>
<script type="text/javascript">/* <![CDATA[ */(function(d,s,a,i,j,r,l,m,t){try{l=d.getElementsByTagName('a');t=d.createElement('textarea');for(i=0;l.length-i;i++){try{a=l[i].href;s=a.indexOf('/cdn-cgi/l/email-protection');m=a.length;if(a&&s>-1&&m>28){j=28+s;s='';if(j<m){r='0x'+a.substr(j,2)|0;for(j+=2;j<m&&a.charAt(j)!='X';j+=2)s+='%'+('0'+('0x'+a.substr(j,2)^r).toString(16)).slice(-2);j++;s=decodeURIComponent(s)+a.substr(j,m-j)}t.innerHTML=s.replace(/</g,'<').replace(/>/g,'>');l[i].href='mailto:'+t.value}}catch(e){}}}catch(e){}})(document);/* ]]> */</script></body>
</html>
frame source is this.
<html>
<head>
<meta charset="utf-8"/>
<meta name="robots" content="noindex, nofollow"/>
...
<link rel="stylesheet" href="/css/bt.css"/>
<link rel="stylesheet" href="/css/style.css"/>
<script src="/js/jquery.js"></script>
<style>body{margin:0!important;}tr{clear:both;cursor:pointer;}td{padding:0 20px 0 0;white-space:nowrap;}.radio{margin-top:5px;margin-bottom:5px;}.small{padding:0;font-size:85%;}#media (max-width: 319px) {table{font-size:12px;}}#media (max-width: 480px) {td{padding:0 5px 0 0;}.small{font-size:50%;}}</style>
</head>
<body>
<form id="format" method="post">
<input name="id" type="hidden" value="isxklqy5blw9of7"/>
<table>
<tr>
<td class="small">
<div class="">
<div class="radio " id="undefined-wrapper">
<label class="text-capitalize" for="undefined">
<input id="undefined" name="format" type="radio" value="undefined" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>I don't care</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td class="small">
<div class="">
<div class="radio " id="160-wrapper">
<label class="text-capitalize" for="160">
<input id="160" name="format" type="radio" value="160" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>256x144</td>
<td></td>
<td>
30 FPS
</td>
<td>23.2 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="133-wrapper">
<label class="text-capitalize" for="133">
<input id="133" name="format" type="radio" value="133" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>426x240</td>
<td></td>
<td>
30 FPS
</td>
<td>51.2 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="134-wrapper">
<label class="text-capitalize" for="134">
<input id="134" name="format" type="radio" value="134" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>640x360</td>
<td></td>
<td>
30 FPS
</td>
<td>65.4 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="135-wrapper">
<label class="text-capitalize" for="135">
<input id="135" name="format" type="radio" value="135" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>854x480</td>
<td></td>
<td>
30 FPS
</td>
<td>138.0 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="136-wrapper">
<label class="text-capitalize" for="136">
<input id="136" name="format" type="radio" value="136" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>1280x720</td>
<td>HD</td>
<td>
30 FPS
</td>
<td>272.2 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="298-wrapper">
<label class="text-capitalize" for="298">
<input id="298" name="format" type="radio" value="298" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>1280x720</td>
<td>HD</td>
<td>
60 FPS
</td>
<td>385.0 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="137-wrapper">
<label class="text-capitalize" for="137">
<input id="137" name="format" type="radio" value="137" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>1920x1080</td>
<td>Full HD</td>
<td>
30 FPS
</td>
<td>535.0 MB</td>
</tr><tr>
<td class="small">
<div class="">
<div class="radio " id="299-wrapper">
<label class="text-capitalize" for="299">
<input id="299" name="format" type="radio" value="299" onchange="" undefined required />
<span class=circle></span><span class=check></span>
<span class="grey-text"></span>
</label>
</div>
</div>
</td>
<td>1920x1080</td>
<td>Full HD</td>
<td>
60 FPS
</td>
<td>707.0 MB</td>
</tr>
</table>
<button class="btn center" type="submit">Proceed »</button>
</form>
</body>
<script>
$('tr').click(function() {
$(this).find('input').prop('checked', true);
});
</script>
<script src="/waves/waves.min.js"></script>
<script>
Waves.attach('.btn', ['waves-light']);
Waves.init();
</script>
html and frame sources are very long code, you can be check this full code.
html link
frame link
and I tried these codes, but don't work.
driver.switch_to_frame(driver.find_element_by_xpath('//iframe[contains(#name, "frame")]'))
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
driver.switch_to_frame(driver.find_element_by_xpath('//iframe'))
driver.switch_to_frame(0)
these iframe switching codes are any exception is nothing, but result is '[]'.
>>> driver.switch_to_frame(driver.find_element_by_xpath('//iframe'))
>>> driver.find_elements_by_xpath("//*[#type='radio']")
[]
>>> driver.find_elements_by_xpath("//*[#type='radio']")[0].click()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
I needs your help. thanks you.
As I'm seeing on this url, there are multiple iframe present while, you are trying to switch to iframe with it's tagName only which will switch to first find iframe in order while your desired iframe is at 4th index which has no id and name attribute present, so you should try using CSS_SELECTOR with WebDriverWait using EC.frame_to_be_available_and_switch_to_it which will try to wait until desired iframe to be available and then switch to it as below working code :-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe:not([id]):not([name])")))
#now do your stuff to find element inside this iframe
#after doing all stuff inside this iframe switch back to default content for further steps
driver.switch_to_default_content()
Note:- You can also consider below one of these options to switch your desired iframe :-
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, ".//iframe[not(#name) and not(#id)]")))
or
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe[src*='selectFormat']")))
or using index :-
wait.until(EC.frame_to_be_available_and_switch_to_it(3))
The iframe is inside <noscript> tag, witch means the driver will see it only when javascript is disabled, as human user would. You can try to disable javascript when creating the driver
fp = webdriver.FirefoxProfile()
fp.set_preference("javascript.enabled", False)
driver = webdriver.Firefox(firefox_profile=fp)
I have created a simple method for switching the frames :
**public static void fn_SwitchToFrame(WebDriver driver, String frame){
if(frame.contains(">")){
String[] List = frame.split(">");
int ListSize = List.length;
for (int i=0; i<=(ListSize-1); i++){
driver.switchTo().frame(List[i]);
System.out.println("Switched to Frame :"+List[i]);
}
} else {
driver.switchTo().frame(frame);
System.out.println("Switched to Frame :"+frame);
}
}**
It works like this :
className.fn_SwitchToFrame(driver, "searchView>searchContent");
This will first switch to frame 'searchView' and then to 'searchContent'.
Hope this helps you.
I am using bottle framework and python to make a website. After using bootstrap, the submit button of my form is not working.
Here is my code in the button3.tpl file:
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Insert Artist</h1>
</div>
<hr>
<div class="container"
<form role="form" method="post" action="/result4">
<div class="form-group">
<laber>National ID</label>
<input class="form-control" type="text" name="ID" value=""><br>
</div>
<div class="form-group">
<laber>Name</label>
<input class="form-control" type="text" name="Name" value=""><br>
</div>
<div class="form-group">
<laber>Surname</label>
<input class="form-control" type="text" name="Surname" value=""><br>
<div class="form-group">
<label>Birth Year</label>
<input class="form-control" type="number" name="Birth" min="1900" max="2016"><br>
</div>
<input class="form-control" type="submit" value="Update Information">
</form>
</div>
<hr>
</body>
Why does it not redirect in the proper link ?
I've been trying to submit a form using requests and urllib (separately), but without much success.
Printing the response shows the relevant fields are actually filled, but the form is not sent.
Here's the code python i've used (the form_data and url were changed of course)
import urllib
import urllib.request
import urllib.parse
import requests
form_data = {'username':'amiti9124#gmail.com',
'pass':'123456',
'passC':'123456',
'Fname':'amitiamiti',
'Tkav':'039111111',
'Cname':'abc',
'Creditme':'2',
'numberOfFaxes':10,
'faxNumber1':'039555555'}
url = "www.someurl.com"
req = requests.post(url,form_data)
print(req.content.decode('UTF-8'))
EDIT:A PART OF THE OUTPUT IS ALSO ADDED
<form action="" method="POST">
<div id="menues">פרטי מנוי</div>
<div id="titles"><font color="red" >*</font> כתובת מייל :
<br />
<input id="inputs" type="text" class="" dir="ltr" style="text-align:left; direction: ltr;" name="username" value='amiti9124#gmail.com' />
</div>
<div id="titles"><font color="red" >*</font>סיסמה :
<br />
<input id="inputs" type="password" class="" name="pass" dir="ltr" style="text-align:left; direction: ltr;" value=123456 />
</div>
<div id="titles"><font color="red" >*</font>אימות סיסמה :
<br />
<input id="inputs" type="password" name="passC" class="" dir="ltr" style="text-align:left; direction: ltr;" value=123456 />
</div>
<div id="titles"><font color="red" >*</font>שם מלא :
<br />
<input id="inputs" type="text" name="Fname" class="" value='amiti amiti' />
</div>
<div id="titles"><font color="red" >*</font>טלפון :
<br />
<input id="inputs" type="text" name="Tkav" class="" dir="ltr" value='039111111' />
</div>
<div id="titles">שם חברה (לחשבונית) :
<br />
<input id="inputs" type="text" name="Cname" value='abc' />
</div>
<div id="titles" class="paidOrTrial">
<input type="radio" id="Creditme" name="Creditme" value="1" style="width: 20px; height: 20px; vertical-align: middle;" />
המשך לתשלום בכרטיס אשראי.
<br />
<input type="radio" id="trialAccount" name="Creditme" checked="checked" value="2" style="width: 20px; height: 20px; vertical-align: middle;"/>
בקשת יתרת התנסות/חשבון נסיון
</div>
<div id="titles" style="display: none; padding: 5px 0 5px 0;">כמות פקסים צפויה לחודש:
<input type="number" id="numberOfFaxes" name="numberOfFaxes" min="0" max="300" step="10" style="width: 40px;" value='10' dir="ltr"/>
<div id="err_msg_number" style="display: none; color: red;"></div>
</div>
<div id="numberOfFaxesWrapper" style="display: none;">
<div id="titles" style="padding: 10px 0px;">חשבון ההתנסות יאפשר שליחת פקסים ל 3 המספרים הבאים :</div>
<div id="titles">מספר פקס 1 :
<br />
<input id="inputs" class="" type="text" name="faxNumber1" dir="ltr" value='039555555' />
</div>
<div id="titles">מספר פקס 2 :
<br />
<input id="inputs" class="" type="text" name="faxNumber2" dir="ltr" />
</div>
<div id="titles">מספר פקס 3 :
<br />
<input id="inputs" class="" type="text" name="faxNumber3" dir="ltr" />
</div>
</div>
<input type="submit" name="Button2222" value="הרשם" style="margin: 6px 0pt; padding: 0px 5px; font-size: 130%; font-weight: bold; color: rgb(0, 0, 0);">
</form>
I'd be grateful if anyone could point me to the solution.
Thanks in advnace !
Try using
req = requests.post(url, data=form_data)
Without the keyword you have little idea which parameter your data argument is being associated with, but it's probably not data.
requests.post(url,form_data) does send data. The sent http request is:
POST /path?query HTTP/1.1
Host: example.com
Content-Length: 146
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate, compress
Accept: */*
User-Agent: python-requests/x.x.x CPython/y.y.y Linux/z.z.z
username=amiti9124%40gmail.com&Cname=abc&Creditme=2&Fname=amitiamiti&pass=123456&numberOfFaxes=10&faxNumber1=039555555&Tkav=039111111&passC=123456
You could send the form manually in your browser and compare the requests.
The html that you see is the response from the server, after it has received your post request.