How do I integrate Bokeh with Angular 4? - python
I have bokeh plot being generated in the backend, which I want to embed onto an already existing angular 4 webapp.
Currently I've use the bokeh.components function which yields the following two html tags.
<script type="text/javascript">
(function() {
var fn = function() {
Bokeh.safely(function() {
(function(root) {
function embed_document(root) {
var docs_json = '{"d199dc51-c663-4220-800f-a5f0d7c3a97a":{"roots":{"references":[{"attributes":{"bottom_units":"screen","fill_alpha":{"value":0.5},"fill_color":{"value":"lightgrey"},"left_units":"screen","level":"overlay","line_alpha":{"value":1.0},"line_color":{"value":"black"},"line_dash":[4,4],"line_width":{"value":2},"plot":null,"render_mode":"css","right_units":"screen","top_units":"screen"},"id":"f795b234-3b1e-4117-aa31-bccbbaaccf71","type":"BoxAnnotation"},{"attributes":{"axis_line_color":{"value":null},"formatter":{"id":"8c794376-5b4c-42f6-bcf4-662922d47df1","type":"BasicTickFormatter"},"major_tick_line_color":{"value":null},"minor_tick_line_color":{"value":null},"plot":{"id":"6fbff9b0-a4fc-4fc1-a50e-d34f906928b2","subtype":"Figure","type":"Plot"},"ticker":{"id":"5468ade8-3979-45b4-9dd0-fbb3cab5b888","type":"BasicTicker"},"visible":null},"id":"be01b966-482b-4e6f-8c6f-8bc0373791aa","type":"LinearAxis"},{"attributes":{},"id":"f9e57a1a-b5e1-4c3f-8e0d-4789dca393ec","type":"SaveTool"},{"attributes":{"fill_color":{"value":"#6C69EB"},"height":{"value":0.5},"right":{"field":"Sales"},"y":{"field":"ID"}},"id":"4dc67234-e29e-4e53-997c-3a6b2e40d5e5","type":"HBar"},{"attributes":{},"id":"db86af55-1185-4097-839a-8d5dc01f19a2","type":"LinearScale"},{"attributes":{},"id":"538fede7-868b-4740-a75e-cb6065ac1194","type":"ResetTool"},{"attributes":{"source":{"id":"946bc6d9-32c8-4dfe-8d34-a29c7c06a242","type":"ColumnDataSource"}},"id":"4ff758a6-c013-4e17-ae69-5c039b0c9394","type":"CDSView"},{"attributes":{"callback":null,"factors":["1348","1226","1306","1268","1103","1129","1340","1470","1783","1346","1264","1387","1775","1247","1771","1770","1773","1772","1190","1733","1727","1694","1584","1503","1113","404","403","401","509","1119","1653","1467","1677","1670","1565","1391","1699","995","1235","1314","1759","1218","1336","1553","1668","1134","1493","1742","1561","1501","1567","1676","1678","1251","1664","1056","1557","1753","1602","1288","1438","1657","1681","1604","1768","1105","1750","1009","1361","1666","1259","1766","1382"]},"id":"2949c368-f95d-4a48-addb-988e5d963ff9","type":"FactorRange"},{"attributes":{},"id":"925e5c0f-b284-4614-a702-33c0ee4bcf34","type":"WheelZoomTool"},{"attributes":{"grid_line_color":{"value":null},"plot":{"id":"6fbff9b0-a4fc-4fc1-a50e-d34f906928b2","subtype":"Figure","type":"Plot"},"ticker":{"id":"5468ade8-3979-45b4-9dd0-fbb3cab5b888","type":"BasicTicker"}},"id":"b1bd251f-e88f-46f1-ac91-5ab1d74ece4b","type":"Grid"},{"attributes":{},"id":"4f69bbc9-c6df-4c64-976c-9013fddff8db","type":"CategoricalTickFormatter"},{"attributes":{"callback":null,"tooltips":"\\n <div>\\n <div>\\n <span style=\\"font-size: 10px;\\">Merch_Ifonafed:</span>\\n <span style=\\"font-size: 15px; font-weight: bold;\\">#ID</span>\\n <div>\\n \\n <div>\\n <span style=\\"font-size: 10px;\\">Revenue:</span>\\n <span style= font-size:15px; font-weight: bold;>₹</span> \\n <span style=\\"font-size: 15px; font-weight: bold;\\">#Sales{0,0.000}</span>\\n <div>\\n \\n <div>\\n <span style=\\"font-size: 10px;\\">Visits:</span>\\n <span style=\\"font-size: 15px; font-weight: bold;\\">#Count</span> \\n <div>\\n \\n <div>\\n <span style=\\"font-size: 10px;\\">Avg Val/Tr:</span>\\n <span style= font-size:15px; font-weight: bold;>₹</span> \\n <span style=\\"font-size: 15px; font-weight: bold;\\">#AVG</span>\\n\\n \\n <div>\\n \\n <div>\\n <span style=\\"font-size: 10px;\\">Mode:</span>\\n <span style= font-size:15px; font-weight: bold;>₹</span> \\n <span style=\\"font-size: 15px; font-weight: bold;\\">#Mode</span>\\n\\n <div>\\n \\n <div>\\n <span style=\\"font-size: 10px;\\">Unique_Visitors:</span>\\n <span style=\\"font-size: 15px; font-weight: bold;\\">#Unique_guests</span>\\n\\n </div>\\n </div>\\n "},"id":"508c69b2-507e-4091-8056-05e75b6a53bf","type":"HoverTool"},{"attributes":{},"id":"af2d3da9-5a8e-48f8-acb3-43d7d7778809","type":"HelpTool"},{"attributes":{},"id":"3de664c0-c02a-4eda-9c07-7e580557f395","type":"CategoricalScale"},{"attributes":{"axis_line_color":{"value":null},"formatter":{"id":"4f69bbc9-c6df-4c64-976c-9013fddff8db","type":"CategoricalTickFormatter"},"plot":{"id":"6fbff9b0-a4fc-4fc1-a50e-d34f906928b2","subtype":"Figure","type":"Plot"},"ticker":{"id":"89f1fa5c-f135-47df-8383-cb589af6606f","type":"CategoricalTicker"}},"id":"e9113819-fe22-4051-bbaa-c568873d85fe","type":"CategoricalAxis"},{"attributes":{"data_source":{"id":"946bc6d9-32c8-4dfe-8d34-a29c7c06a242","type":"ColumnDataSource"},"glyph":{"id":"4dc67234-e29e-4e53-997c-3a6b2e40d5e5","type":"HBar"},"hover_glyph":null,"muted_glyph":null,"view":{"id":"4ff758a6-c013-4e17-ae69-5c039b0c9394","type":"CDSView"}},"id":"9fed1d26-a3c2-4096-8c12-cca8bc423562","type":"GlyphRenderer"},{"attributes":{"below":[{"id":"be01b966-482b-4e6f-8c6f-8bc0373791aa","type":"LinearAxis"}],"left":[{"id":"e9113819-fe22-4051-bbaa-c568873d85fe","type":"CategoricalAxis"}],"outline_line_alpha":{"value":0.2},"renderers":[{"id":"be01b966-482b-4e6f-8c6f-8bc0373791aa","type":"LinearAxis"},{"id":"b1bd251f-e88f-46f1-ac91-5ab1d74ece4b","type":"Grid"},{"id":"e9113819-fe22-4051-bbaa-c568873d85fe","type":"CategoricalAxis"},{"id":"a48580a8-8254-4b66-a45c-a3e41210d5f4","type":"Grid"},{"id":"f795b234-3b1e-4117-aa31-bccbbaaccf71","type":"BoxAnnotation"},{"id":"9fed1d26-a3c2-4096-8c12-cca8bc423562","type":"GlyphRenderer"}],"title":{"id":"c23880dd-5727-4f94-9e1d-f1ecf3d2f71e","type":"Title"},"toolbar":{"id":"f380e570-a3bb-4430-9bb8-ba214afcf178","type":"Toolbar"},"x_range":{"id":"55df4eae-ccbb-4c6d-afa3-653995f8bb79","type":"DataRange1d"},"x_scale":{"id":"db86af55-1185-4097-839a-8d5dc01f19a2","type":"LinearScale"},"y_range":{"id":"2949c368-f95d-4a48-addb-988e5d963ff9","type":"FactorRange"},"y_scale":{"id":"3de664c0-c02a-4eda-9c07-7e580557f395","type":"CategoricalScale"}},"id":"6fbff9b0-a4fc-4fc1-a50e-d34f906928b2","subtype":"Figure","type":"Plot"},{"attributes":{},"id":"5468ade8-3979-45b4-9dd0-fbb3cab5b888","type":"BasicTicker"},{"attributes":{"plot":null,"text":""},"id":"c23880dd-5727-4f94-9e1d-f1ecf3d2f71e","type":"Title"},{"attributes":{"active_drag":"auto","active_inspect":"auto","active_scroll":"auto","active_tap":"auto","tools":[{"id":"883319d0-a94d-44bd-ad9d-8e7b4a393771","type":"PanTool"},{"id":"925e5c0f-b284-4614-a702-33c0ee4bcf34","type":"WheelZoomTool"},{"id":"ac6748d3-f7ae-4232-8ed3-74432a8f67ab","type":"BoxZoomTool"},{"id":"f9e57a1a-b5e1-4c3f-8e0d-4789dca393ec","type":"SaveTool"},{"id":"538fede7-868b-4740-a75e-cb6065ac1194","type":"ResetTool"},{"id":"af2d3da9-5a8e-48f8-acb3-43d7d7778809","type":"HelpTool"},{"id":"508c69b2-507e-4091-8056-05e75b6a53bf","type":"HoverTool"}]},"id":"f380e570-a3bb-4430-9bb8-ba214afcf178","type":"Toolbar"},{"attributes":{"overlay":{"id":"f795b234-3b1e-4117-aa31-bccbbaaccf71","type":"BoxAnnotation"}},"id":"ac6748d3-f7ae-4232-8ed3-74432a8f67ab","type":"BoxZoomTool"},{"attributes":{"callback":null,"column_names":["Count","AVG","ID","Sales"],"data":{"AVG":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"Count":[11,473,224,12,2522,1,3,1668,4,116,355,248,7,9,2,4,1922,1,1613,62,239,1,135,14,685,303,720,1092,1,264,1384,311,3,1680,903,80,2,337,249,207,1,271,2,1,440,1312,74,1169,3,427,1303,36,46,1002,97,438,2,2,272,1287,1205,212,6,1142,42,925,3,1130,13,692,887,166,446],"ID":["1348","1226","1306","1268","1103","1129","1340","1470","1783","1346","1264","1387","1775","1247","1771","1770","1773","1772","1190","1733","1727","1694","1584","1503","1113","404","403","401","509","1119","1653","1467","1677","1670","1565","1391","1699","995","1235","1314","1759","1218","1336","1553","1668","1134","1493","1742","1561","1501","1567","1676","1678","1251","1664","1056","1557","1753","1602","1288","1438","1657","1681","1604","1768","1105","1750","1009","1361","1666","1259","1766","1382"],"Sales":[14920,113230,50641,2400,585233,0,0,438801,900,56428,116718,89224,0,0,780,0,552609,0,389764,14688,50450,0,28240,2680,147458,89125,183097,266313,0,2094625,499393,90876,10,434509,238438,17970,290,141866,85690,47865,0,71074,320,0,89103,348101,20536,283752,0,138798,341643,8950,8451,335189,23034,125857,0,0,80885,342261,351727,52722,732,324171,11451,245051,0,370611,2310,161049,257464,41871,107453]}},"id":"946bc6d9-32c8-4dfe-8d34-a29c7c06a242","type":"ColumnDataSource"},{"attributes":{"dimension":1,"grid_line_color":{"value":null},"plot":{"id":"6fbff9b0-a4fc-4fc1-a50e-d34f906928b2","subtype":"Figure","type":"Plot"},"ticker":{"id":"89f1fa5c-f135-47df-8383-cb589af6606f","type":"CategoricalTicker"}},"id":"a48580a8-8254-4b66-a45c-a3e41210d5f4","type":"Grid"},{"attributes":{},"id":"883319d0-a94d-44bd-ad9d-8e7b4a393771","type":"PanTool"},{"attributes":{},"id":"89f1fa5c-f135-47df-8383-cb589af6606f","type":"CategoricalTicker"},{"attributes":{"callback":null},"id":"55df4eae-ccbb-4c6d-afa3-653995f8bb79","type":"DataRange1d"},{"attributes":{},"id":"8c794376-5b4c-42f6-bcf4-662922d47df1","type":"BasicTickFormatter"}],"root_ids":["6fbff9b0-a4fc-4fc1-a50e-d34f906928b2"]},"title":"Bokeh Application","version":"0.12.13"}}';
var render_items = [{"docid":"d199dc51-c663-4220-800f-a5f0d7c3a97a","elementid":"74705daf-2fe7-47e6-9800-0ecaf72e9708","modelid":"6fbff9b0-a4fc-4fc1-a50e-d34f906928b2"}];
root.Bokeh.embed.embed_items(docs_json, render_items);
}
if (root.Bokeh !== undefined) {
embed_document(root);
} else {
var attempts = 0;
var timer = setInterval(function(root) {
if (root.Bokeh !== undefined) {
embed_document(root);
clearInterval(timer);
}
attempts++;
if (attempts > 100) {
console.log("Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing")
clearInterval(timer);
}
}, 10, root)
}
})(window);
});
};
if (document.readyState != "loading") fn();
else document.addEventListener("DOMContentLoaded", fn);
})();
</script>
as well as
<div class="bk-root">
<div class="bk-plotdiv" id="74705daf-2fe7-47e6-9800-0ecaf72e9708"></div>
</div>
which I can embed onto a small boilerplate:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Scatter Plots</title>
<link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.6.min.css" type="text/css" />
<script type="text/javascript" src="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.6.min.js"></script>
<script type="text/javascript">
(function() {
var fn = function() {
Bokeh.safely(function() {
(function(root) {
function embed_document(root) {
var docs_json = <!---docs_json---!>
var render_item = <!---items---!>
</head>
<body>
<div class="bk-root">
<div class="bk-plotdiv" id=<!--- div_id ---!>></div>
</div>
</body>
</html>
For this I need to parse out the important variables(docs_json,render_id,div_id) from the first two scripts and then have them sent as a json to the Frontend using Flask. much like this google forms question
https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/McLDXP414ps
Is there a better way to send my bokeh plot to the angular front end, instead of having to go through all of this ?
Related
Converting html + bootstrap files (using flex) into pdf - Django?
I am trying to create a webapp where, the data comes from a certain API and is saved into the database. Now, I want to create a pdf using the data. I had my html Code ready with custom css and bootstrap ( using display: flex; ). I already tried using the xhtml2pdf, reportlab libraries but am not able to get it right with CSS flex properties. The source for the HTML, and some python file are attached below. HTML File: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <title>Invoice-ID</title> <style type="text/css"> /* Bootstrap CSS */ .col-md-7 { flex: 0 0 auto; width: 58%; } .container { width: 1320px; } .bg-light { background-color: #f8f9fa !important; } .nav { display: flex; flex-wrap: wrap; padding-left: 0; margin-bottom: 0; list-style: none; } .justify-content-center { justify-content: center; } .navbar { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-top: .5rem; padding-bottom: .5rem; } .navbar>.container-fluid { display: flex; flex-wrap: inherit; align-items: center; justify-content: space-between; } .navbar-light .navbar-brand { color: rgba(0, 0, 0, .9); } .navbar-brand { padding-top: .3125rem; padding-bottom: .3125rem; margin-right: 1rem; font-size: 1.25rem; text-decoration: none; white-space: nowrap; } .flex-column { flex-direction: column !important; } .d-flex { display: flex !important; } .w-50 { width: 50% !important; } .ms-2 { margin-left: .5rem !important; } .p-3 { padding: 1rem !important; } /* Custom CSS */ body { font-weight: 300; font-size: 14px; } .wrapper { border: 2px solid gray; border-width: 2px; } #location { /* border: 2px solid gray; */ border-right: 1px solid gray; border-width: 1px; margin-bottom: 2rem; } .header { font-size: 20px; font-weight: 100; text-align: center; color: #007cae; } .title { font-size: 22px; font-weight: 100; padding: 10px 20px 0px 20px; } .title span { color: #007cae; } .details { padding: 10px 20px 0px 20px; text-align: left !important; } /* . { margin-left: 455px; } */ .hritem { border: 1px solid gray; border-width: 2px; } </style> </head> <body> <div class="mt-5 container" style="border: 2px solid gray;"> <!-- Header Start --> <div class="d-flex justify-content-center align-items-center"> <!-- <img src="E:\Python\Django web\logiswift\Deployment\main\static\assets\logo.png" alt="Logo" width="350px"> --> <h1>LOGO</h1> <div class="ms-auto"> <span><b>Some Text</b></span> </div> </div> <hr class="hritem"/> <div class="d-flex justify-content-center align-items-center"> <h3>Title</h3> <div class="ms-auto "> <p>Date: 12-12-2021</p> <p>Document ID: 9868</p> </div> </div> <!-- Header End --> <hr class="hritem"/> <!-- General Trip Info Start --> <div class="d-flex"> <div class="w-50" id="location"> <p> <h6>Current Location</h6> <span>Address Line 1,</span> <span>Address Line 2,</span> <span>City,</span> <span>State - PIN</span> </p> <p> <h6>Expected Location</h6> <span>Address Line 1,</span> <span>Address Line 2,</span> <span>City,</span> <span>State - PIN</span> </p> </div> <div class="w-50 ms-2 mt-3" id="consumer"> <h6>consumer Details</h6> <hr/> <p> <span style="font-size: medium; font-weight: 400;"><b>Name: </b></span> <span>Your Name</span> </p> <p> <span style="font-size: medium; font-weight: 400;"><b>Consumer ID: </b></span> <span>Unique Consumer ID</span> </p> </div> </div> <!-- General Trip Info End --> <hr class="hritem"/> <!-- Bill Start --> <!-- <div> <p>Bill Will Come here</p> </div> --> <!-- Bill End --> <!-- <hr class="hritem"/> --> <!-- Footer Start --> <!-- <div> <p>Additional info like address of the company and seal comes here.</p> </div> --> <!-- Footer end --> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> </body> </html> utils.py from io import BytesIO from django.http import HttpResponse from django.template.loader import get_template from xhtml2pdf import pisa def render_to_pdf(template_src, context_dict={}): template = get_template(template_src) html = template.render(context_dict) result = BytesIO() pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result) if not pdf.err: return HttpResponse(result.getvalue(), content_type='application/pdf') return None view.py def generatePDF(request): template = get_template('main/invoices.html') context = { "date": datetime.date.today(), } html = template.render(context) pdf = render_to_pdf('main/invoices.html', context) return HttpResponse(pdf, content_type="application/pdf") I don't understand why the above code isn't rendering the CSS flex attributes. I even tried to use the bootstrap classes inside the style tag, but the CSS flex won't come on rendering the PDF. Please help me out. Thanks in advance
trouble retrieving an email from an username from a text document
so I have this website that allows me to get the email from a user that has signed up to the website, so when you sign up it adds your discord username and your email after it in a text file like this Discorduser#0182 Test#example.com Discordusernumber_one#0182 Testboi#example.co.uk However, it retrieves the email from the first line when i put in the first option, but if i do the 2nd user, it cant seem to find it, here is the code to the website... the code is part of a bottle.py script but here is the main parts of this page #get('/get_confirm') def confirm(): return CONFIRM_PAGE #post('/get_confirm') def confirm(): name = request.forms.get('name') for line in open('Confirmations.txt', 'r').readlines(): login_info = line.replace('\n', '').split() if name == login_info[0]: return CONFIRM_PAGE.replace('''<h1 id='emailbox'></h1>''', '<h1>' + login_info[1] + '</h1>') else: return CONFIRM_PAGE.replace('''<h1 id='emailbox'></h1>''', '<h1>' + 'That user is not valid' + '</h1>') CONFIRM_PAGE = ''' <!DOCTYPE html> <html> <head> <link rel="icon" href="/static/icon.ico"> <title>TylerR - get_confirms</title> <style> .content { background: white; padding: 15px; border-radius: 3px; } ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a, .dropbtn { display: inline-block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover, .dropdown:hover .dropbtn { background-color: red; } li.dropdown { display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } .dropdown-content a:hover {background-color: #f1f1f1} .dropdown:hover .dropdown-content { display: block; } </style> </head> <body style='background-size: cover; background-image: url(\"/static/WebisteBackground.png\"); background-attachment: fixed;'> <ul> <li><a href='/'>Home</a></li> <li><a href='/commands'>Commands</a></li> <li><a href='/youtube'>Youtube</a></li> <li><a href='/downloads'>Downloads</a></li> <a href='https://www.youtube.com/channel/UCTHnGh3DpDXMyuL03ove1tQ'> <img align='right' src='/static/youtubelogo.png' style="width:40px;height:40px;"> </a> <a href='https://www.instagram.com/drumsnaps/'> <img align='right' src='/static/Insta.png' style="width:40px;height:40px;"> </a> </ul> </div> <center> <h1 style="font-family:Cooper Black; font-size: 7em;"><b>Confirmations<b></h1> <br> <h1>Please enter an username to retrieve email</h1> <h3>When entering name, replace any spaces with _</h3> <form method='POST' action='/get_confirm'> <h2>Discord Username:</h2> <input name='name' type='text' placeholder='User#0000'> <br> <input type='submit'> </form> <div class='content'> <h1 id='emailbox'></h1> </div> </center> </body> </html> ''' I am using bottle.py so if anyone could let me know why this is happening that would be great
In your check it returns immediately - with success (if user is on the first line) or no success (if user is not on first line). You want to return no success, only after you checked all lines. #post('/get_confirm') def confirm(): name = request.forms.get('name') with open('Confirmations.txt', 'r') as f: for line in f: user, email = line.strip().split() if name == user: return CONFIRM_PAGE.replace('''<h1 id='emailbox'></h1>''', '<h1>' + email + '</h1>') return CONFIRM_PAGE.replace('''<h1 id='emailbox'></h1>''', '<h1>' + 'That user is not valid' + '</h1>') Also, better use template engine like jinja2 to construct the HTML page.
Python selenium iframe [duplicate]
This question already has answers here: CSS selector for reCAPTCHA checkbok using Selenium and VBA Excel (1 answer) Find the reCAPTCHA element and click on it -- Python + Selenium (2 answers) How to click on the reCAPTCHA using Selenium and Java (5 answers) Closed 3 years ago. I am trying to switch to iframe in captcha, but I get this error selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: The result of the xpath expression "//iframe" is: [object HTMLIFrameElement]. It should be an element. I tryed with switcing to Iiframe, but it doesnt work, I find iframe with inspecting element, but I can not find element when I run the script, also I added explicit wait, time sleep, but it still doesn't work here is html code <html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Access to this page has been denied.</title> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet"> <style> html, body { margin: 0; padding: 0; font-family: 'Open Sans', sans-serif; color: #000; } a { color: #c5c5c5; text-decoration: none; } .container { align-items: center; display: flex; flex: 1; justify-content: space-between; flex-direction: column; height: 100%; } .container > div { width: 100%; display: flex; justify-content: center; } .container > div > div { display: flex; width: 80%; } .customer-logo-wrapper { padding-top: 2rem; flex-grow: 0; background-color: #fff; visibility: hidden; } .customer-logo { border-bottom: 1px solid #000; } .customer-logo > img { padding-bottom: 1rem; max-height: 50px; max-width: 100%; } .page-title-wrapper { flex-grow: 2; } .page-title { flex-direction: column-reverse; } .content-wrapper { flex-grow: 5; } .content { flex-direction: column; } .page-footer-wrapper { align-items: center; flex-grow: 0.2; background-color: #000; color: #c5c5c5; font-size: 70%; } #media (min-width: 768px) { html, body { height: 100%; } } </style> <script src="/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v="></script><style type="text/css">.px-loader-wrapper { display: flex;}#keyframes loadingEffect { 0% { background-position: 0; } 100% { background-position: 60vw; }}.px-inner-loading-area { width: 310px; height: 30px; animation-name: loadingEffect; animation-duration: 1.2s; animation-iteration-count: infinite; animation-timing-function: ease; animation-fill-mode: forwards; background: linear-gradient(to right, #F6F6F6 8%, #F0F0F0 18%, #F6F6F6 33%);}.px-loading-area { width: 310px; height: 30px; margin: 0; ;}</style><script src="/rw7M6iAV/init.js"></script><a tabindex="-1" aria-hidden="true" href="/organization/waldeck-associates?_pxhc=1575828688573" rel="nofollow" target="_blank" style="width: 0px; height: 0px; font-size: 0px; line-height: 0;"></a></head> <body> <section class="container"> <div class="customer-logo-wrapper"> <div class="customer-logo"> <img src="" alt="Logo"> </div> </div> <div class="page-title-wrapper"> <div class="page-title"> <h1>Please verify you are a human</h1> </div> </div> <div class="content-wrapper"> <div class="content"> <div id="px-captcha" role="main"><style>#media screen and (max-width: 350px) { #px-captcha { position: relative; right: 32px; } }</style><iframe style="display: block; width: 310px; height: 100px; border: 0; padding:0; margin: 0; -moz-user-select: none;-khtml-user-select: none;-webkit-user-select: none;-ms-user-select: none;user-select: none;" token="efbbf8834a03575dcd9c41ce37a32800bac150d7be5c1b3bf3a953f0879cfc3caa53da776440a3d731e03394daec916c92fe9416ba7947d3cea7370b970a551d"></iframe></div> <p> Access to this page has been denied because we believe you are using automation tools to browse the website. </p> <p> This may happen as a result of the following: </p> <ul> <li> Javascript is disabled or blocked by an extension (ad blockers for example) </li> <li> Your browser does not support cookies </li> </ul> <p> Please make sure that Javascript and cookies are enabled on your browser and that you are not blocking them from loading. </p> <p> Reference ID: #266c5db0-19e6-11ea-8150-878a39a29362 </p> <div id="px-block-form-wrapper"><div><style>#px-block-form-wrapper{width:400px;position:absolute;bottom:0;left:calc(50% - 200px)}#px-block-toggle-button{height:20px;background:#fff;color:#000;border-radius:3px;padding:10px;cursor:pointer;font-size:13px;text-align:center;width:270px;border:1px solid #000;font-weight:900;margin-left:75px;text-decoration:underline}#px-block-form{background:#fff;border:1px solid;border-color:#404040;color:#000;border-radius:3px;height:265px;font-size:12px}button#px-form-close{float:right;background:0 0;border:none;color:#fff;font-size:18px;cursor:pointer}button#px-form-submit{position:absolute;bottom:10px;background:#404040;border:none;width:100px;border-radius:3px;height:25px;color:#fff;right:20px;cursor:pointer}button#px-form-submit:disabled{background:#ddd;cursor:not-allowed;color:#000}div#px-form{color:#000;padding:15px}div#px-form-head{padding:10px;font-size:14px;background:#404040;color:#fff}div#px-form textarea{margin:-5px 0 0 4px;width:300px;height:36px}div#px-form div{margin-bottom:6px}#px-form-thank-you{background:#fff;color:#000;border:1px solid;border-color:#404040;border-radius:3px;height:54px;padding:5px 10px;text-align:center;width:330px;margin-left:35px}#px-form-thank-you div{font-size:15px;margin-top:14px}#px-form-thank-you span.checkmark{margin-right:8px;color:green;font-size:20px}div#px-form form h4{margin:8px 4px}#media only screen and (orientation:portrait){#px-block-form-wrapper{width:97%;position:relative;left:3%;z-index:10}#px-block-toggle-button{height:20px;background:#fff;color:#000;padding:3px;cursor:pointer;font-size:13px;text-align:center;width:94%;border:none;font-weight:900;text-decoration:underline;margin-left:0;position:fixed;bottom:5px;right:10px;width:initial}#px-block-form{background:#fff;border:1px solid;border-color:#404040;color:#000;border-radius:3px;height:250px;font-size:12px}button#px-form-close{float:right;background:0 0;border:none;color:#fff;font-size:18px;cursor:pointer;position:absolute;right:15px;padding:0;bottom:6px}button#px-form-submit{position:absolute;bottom:10px;background:#404040;border:none;width:100px;border-radius:3px;height:25px;color:#fff;right:20px;cursor:pointer;font-size:13px}button#px-form-submit:disabled{background:#ddd;cursor:not-allowed;color:#000}div#px-form{color:#000;padding:15px}div#px-form-head{padding:10px;font-size:14px;background:#404040;color:#fff;position:relative}div#px-form textarea{margin:-5px 0 0 4px;width:90%;height:36px}div#px-form div{margin-bottom:6px}#px-form-thank-you{background:#fff;color:#000;border:1px solid;border-color:#404040;border-radius:3px;height:54px;padding:5px 10px;text-align:center;width:94%;margin-left:0}#px-form-thank-you div{font-size:15px;margin-top:14px}#px-form-thank-you span.checkmark{margin-right:8px;color:green;font-size:20px}div#px-form form h4{margin:8px 4px}.container{display:block;position:relative}.container .content-wrapper{padding-bottom:40px}.container .page-footer-wrapper{position:fixed;bottom:0}.container .content-wrapper .content{margin:0 auto}}</style><div id="px-block-toggle-button" onclick="_pxToggleOpenForm()" hidden="">Report an issue</div><div id="px-block-form"><div id="px-form-head"><span>Experiencing issues? Let us know:</span> <button onclick="_pxToggleOpenForm(!0)" id="px-form-close">X</button></div><div id="px-form"><form><div style="display:none"><input onchange="_pxItemSelected()" type="radio" id="opt0" name="px-report-reason" value="-1"> <label for="opt0">I’m a bot</label></div><div><input onchange="_pxItemSelected()" type="radio" id="opt1" name="px-report-reason" value="1"> <label for="opt1">I don’t see any challenge</label></div><div><input onchange="_pxItemSelected()" type="radio" id="opt2" name="px-report-reason" value="2"> <label for="opt2">I keep solving the challenge</label></div><div><input onchange="_pxItemSelected()" type="radio" id="opt3" name="px-report-reason" value="3"> <label for="opt3">Other (please elaborate)</label></div><h4>Additional Information:</h4><textarea id="px-form-free-text" placeholder="Experiencing other issues?"></textarea></form><button disabled="disabled" id="px-form-submit" onclick="_pxSubmitForm()">Send</button></div></div><div hidden="" id="px-form-thank-you"><div><span class="checkmark">✓</span><span>Thank you for the feedback</span></div></div></div></div></div> </div> <div class="page-footer-wrapper"> <div class="page-footer"> <p> Powered by PerimeterX , Inc. </p> </div> </div> </section> <script> window._pxAppId = 'PXrw7M6iAV'; window._pxJsClientSrc = '/rw7M6iAV/init.js'; window._pxFirstPartyEnabled = true; window._pxVid = ''; window._pxUuid = '266c5db0-19e6-11ea-8150-878a39a29362'; window._pxHostUrl = '/rw7M6iAV/xhr'; </script> <script> var s = document.createElement('script'); s.src = '/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v='; var p = document.getElementsByTagName('head')[0]; p.insertBefore(s, null); if (true) { s.onerror = function () { s = document.createElement('script'); var suffixIndex = '/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v='.indexOf('captcha.js'); var temperedBlockScript = '/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v='.substring(suffixIndex); s.src = '//captcha.px-cdn.net/PXrw7M6iAV/' + temperedBlockScript; p.parentNode.insertBefore(s, p); }; } </script> </body></html>
The exception itself says that the selector is incorrect. Try to use absolute xpath while selecting the iFrame. Absolute xpath for captcha iframe always works for me. Also it woulbe be great if you can share your automation code
use textarea for python input() to Skulpt
i want to use a textarea whenever the Python input() function is run in Skulpt. The default is to use an alert box - i want to use a textarea instead. i've tried to get this working, but nothing happens when i try this example: https://github.com/skulpt/skulpt/issues/685 everything else works fine as i want it. please help! :D <!DOCTYPE html> <html lang="en"> <head> <script src="js/jquery-3.2.1.min.js" type="text/javascript"></script> <script src="js/debugger.js" type="text/javascript"></script> <script src="js/skulpt.min.js" type="text/javascript"></script> <script src="js/skulpt-stdlib.js" type="text/javascript"></script> <title>i dont like the alert boxes</title> <style type="text/css" media="screen"> #source{ position: relative; width: 500px; height: 300px; } #console{ position: relative; width: 500px; height: 100px; overflow: scroll; } body{ background-color: whitesmoke; } #turtleCanvas{ position: relative; border: 1px; border-color: firebrick; border-collapse: collapse; border-style: solid; width: 500px; } </style> <script src="js/brython/brython.js" type="text/javascript"></script> </head> <body onload="brython()"> <script type="text/javascript"> function outf(text) { var mypre = document.getElementById("console"); mypre.innerHTML = mypre.innerHTML + text; } function builtinRead(x) { if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined) throw "File not found: '" + x + "'"; return Sk.builtinFiles["files"][x]; } function runit() { var editor = ace.edit("source"); var code = editor.getValue(); document.getElementById("hiddenCode").innerHTML = code; var prog = document.getElementById("hiddenCode").value; var mypre = document.getElementById("console"); mypre.innerHTML = ''; Sk.pre = "console"; Sk.configure({output:outf, read:builtinRead}); (Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'turtleCanvas'; var myPromise = Sk.misceval.asyncToPromise(function() { return Sk.importMainWithBody("<stdin>", false, prog, true); }); myPromise.then(function(mod) { console.log('success'); }, function(err) { console.log(err.toString()); }); } </script> <textarea id="hiddenCode" style="display:none;"></textarea><br /> <div id="source">import turtle myName = input("who r u?") print(myName) t = turtle.Turtle() t.forward(100)</div> <button type="button" onclick="runit()">Run</button> <textarea id="programInputField">some input lines</textarea> <pre id="console">output</pre> <div id="turtleCanvas"></div> <script src="js/ace/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script> var window1 = ace.edit("source"); var window2 = ace.edit("console"); window1.setTheme("ace/theme/textmate"); window2.setTheme("ace/theme/twilight"); window1.getSession().setMode("ace/mode/python"); </script> </body>
Never mind!!!! This worked perfectly, just had to change the id of my text area, otherwise i just copied and pasted it and commented out my own sk.configure line..... brilliant, thankyou whoever you are!!!!!!! :D :D :D :D Wait for an event to occur within a function in Javascript for Skulpt
Using Selenium to find elements related to drop down list from another frame -- Python
I have been trying to write a program to automate my work. My task has series of steps but I am stuck at one point. I am constantly getting NoSuchElementException. I have tried to use id, class, name methods of Selenium but nothing seems to work. My present code is this: from selenium import webdriver from selenium.webdriver.common.by import By browser = webdriver.Chrome('C:\\Users\\abc\\AppData\\Local\\Programs\\Python\\Python36\\chromedriver.exe') browser.get("http://example.com/login.aspx") usernameElem = browser.find_element_by_id('txtuser') usernameElem.send_keys('admin') passwordElem = browser.find_element_by_id('txtpassword') passwordElem.send_keys('password') loginElem = browser.find_element_by_id('btn_login') loginElem.click() # follows the "Read It Online" link browser.get("http://example.com/Reports.aspx") subscriberslistElem = browser.find_element_by_id('ContentPlaceHolder1_rptDC_lnk_0') subscriberslistElem.click() browser.implicitly_wait(3) entityElem = browser.find_element_by_id("report_Entity_ClientState") print("Test") entityElem.send_keys('Entity1') browser.implicitly_wait(3) reportElem = browser.find_element_by_class_name('selectbox') print("Test 2") reportElem.click() showdataElem = browser.find_element_by_id('btn_new') showdataElem.click() excelElem = browser.find_element_by_id('imgExport') excelElem.click() print('All is well') Link to webpage, complete files. It's strange that when I opened HTML file online as code and searched 'report_Entity_ClientState' there were no results. Images of elements I am trying to access: First element. Second element. Both the entity and report element are not found. Following parts of code return error. entityElem = browser.find_element_by_id("report_Entity_ClientState") reportElem = browser.find_element_by_class_name('selectbox') entityElem.send_keys('Entity1') browser.implicitly_wait(3) HTML code of elements: <html xmlns="http://www.w3.org/1999/xhtml"><head><title> </title> <style type="text/css"> .rgDataDiv { height: 350px !important; } #report2_demo1_dateInput, #report2_demo2_dateInput { background: none repeat scroll 0 0 #f0f3f4; border: 1px solid #4D87A5; border-radius: 0.3em; color: #296872; font-family: "HelveticaNeue-Light" , "Helvetica Neue Light" , "Helvetica Neue" ,Helvetica,Arial, "Lucida Grande" ,sans-serif; font-size: 14px; font-weight: 400; height: 1.8em; padding: 0 0.3em; position: relative; text-align: center; text-shadow: 1px 1px 0 #FFFFFF; } .selectbox { width: 175px; height: 27px; background-color: #FFF; border: 1px solid #b7b7b7; font: 400 12px/18px 'Open Sans' , sans-serif; color: #777; font-weight: bold; border: 1px solid #ccc; margin: 0em 0.5em; padding: 0em 0.5em; box-shadow: 0 0 1px rgba(0, 0, 0, 0.2); } .selectbox:hover { border: 1px solid #1261ac !important; } .selectbox option { padding: 5px; } .button { background-color: #23ad44; background-image: linear-gradient(to bottom, #23ad44, #23ad44); border: 1px solid #23ad44; border-radius: 3px; color: #ffffff; display: inline-block; font-family: arial,helvetica,sans-serif; font-size: 12px; font-weight: bold; margin-left: 5px; padding: 7px; text-align: center; text-decoration: none; width: 7em; } .button:hover { background-color: #23ad44; background-image: linear-gradient(to bottom, #23ad44, #23ad44); border: 1px solid #23ad44; } </style> <style type="text/css"> #overlay { background-color: #000000; height: 100%; left: 0; opacity: 0.6; position: fixed; top: 0; width: 100%; z-index: 1500; } #theprogress { background-color: #000000; border: 0 solid #CCCCCC; height: 30px; line-height: 30px; opacity: 0.6; padding: 10px; text-align: center; width: 300px; } #modalprogress { position: absolute; top: 45%; left: 50%; margin: -11px 0 0 -150px; color: #990000; font-weight: bold; font-size: 14px; } .RepeaterLabel { color: #2980b9; } </style> <link href="/WebResource.axd?d=YhrvG3mKYx0qi8zmG_e2lyIXyb_ANuRBo_sKLQFJLSvTN5PZ_1mAdbAu2oYdNj8IQ2baXlFznJaZLu1FNyX1Sw2&t=634968929080000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet"><link href="/WebResource.axd?d=pgzM84zOvBy03oK1BX9qj4AemgkqjvEpKd1DaZn3BmX7HYCaCPA9mDXES3WITAYhGWLhU3BijsiI-NqfoTxwKTiVY41t_WUGeTj39PR75xY1&t=634968929080000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet"></head> <body> <form method="post" action="Rep1_SubList.aspx" id="form1"> <div class="aspNetHidden"> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value=""> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value=""> <input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value=""> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTIwNjA3NzE2NzEPZBYCAgMPZBYCAgEPZBYCZg9kFggCBQ8UKwACDxYEHgtfIURhdGFCb3VuZGceF0VuYWJsZUFqYXhTa2luUmVuZGVyaW5naGQPFCsAAhQrAAIPFgIeBFRleHQFA0FMTGRkFCsAAg8WBB8CBQhTUENHMDAzMx4FVmFsdWUFCFNQQ0cwMDMzZGQPFCsBAmZmFgEFd1RlbGVyaWsuV2ViLlVJLlJhZENvbWJvQm94SXRlbSwgVGVsZXJpay5XZWIuVUksIFZlcnNpb249MjAxMy4xLjIyMC40MCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0xMjFmYWU3ODE2NWJhM2Q0FghmDw8WBB4IQ3NzQ2xhc3MFCXJjYkhlYWRlch4EXyFTQgICZGQCAQ8PFgQfBAUJcmNiRm9vdGVyHwUCAmRkAgIPDxYCHwIFA0FMTGRkAgMPDxYEHwIFCFNQQ0cwMDMzHwMFCFNQQ0cwMDMzZGQCCQ8QZGQWAWZkAgsPEGRkFgFmZAIVDzwrAA4CABQrAAJkFwEFCFBhZ2VTaXplAhQBFgIWC2RkZRQrAAALKXlUZWxlcmlrLldlYi5VSS5HcmlkQ2hpbGRMb2FkTW9kZSwgVGVsZXJpay5XZWIuVUksIFZlcnNpb249MjAxMy4xLjIyMC40MCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0xMjFmYWU3ODE2NWJhM2Q0ATwrAAcACyl0VGVsZXJpay5XZWIuVUkuR3JpZEVkaXRNb2RlLCBUZWxlcmlrLldlYi5VSSwgVmVyc2lvbj0yMDEzLjEuMjIwLjQwLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQBZGRkZGYWAmYPFCsAAhQrAAIUKwACZGRkZGQYAgUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFDXJlcG9ydF9FbnRpdHkFDXJlcG9ydF9FbnRpdHkPFCsAAmVlZLr0AotH53uxPGSh7QymTeWwsdUnInQbJfo/1AqZAer9"> </div> <script type="text/javascript"> //<![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> </script> <script src="/WebResource.axd?d=WPqzNIAf0aRvfZ51T5FqAw2&t=636265663681012204" type="text/javascript"></script> <script src="/ScriptResource.axd?d=0-K2f-KkPKroL1v8HQRfqOW6Bm5xtYnbtzo_BRMK3-orTVPkM3P6U7R-O_kYNMldQbgeLIbAfjb5i99L3QDP87wvzxMxirCvs4zeaZ5iCvg1&t=16ab2387" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.'); //]]> </script> <script src="/ScriptResource.axd?d=0-K2f-KkPKroL1v8HQRfqOW6Bm5xtYnbtzo_BRMK3-orTVPkM3P6U7R-O_kYNMldkzOjZKCZKI8dbMwhU6puwXriFBMbrnAMLgehz7nDFguuKxruf9QzOB5sQpy88shJ0&t=16ab2387" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCdnEq-SEy_US1KuLZmEnoxm0&t=ffffffffcf4a174e" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCcCRUgx0Nxj77KymelI6SbiewHQsPnET8txjQRIhxv9ow2&t=ffffffffcf4a174e" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCf49iuFjicOUhj3AUMkpbwDvPtFtRMJzCdeNbcfmY9RdA2&t=ffffffffcf4a174e" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCcStsFzhAvG6xzv928b3E8L1Pt9Gjfq_pIz-VgKJtG5wQ2&t=ffffffffcf4a174e" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCdT9MJqqpr-t50oq7GfpGoHVIJkcb_99EGhaoMesY6BL_Y4gIEI-tQ29AH-8m3OqeM1&t=ffffffffcf4a174e" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCdT9MJqqpr-t50oq7GfpGoHGGMRnTUBSrYO6OmjVxnhB1zYMtRDZSpvvOn8lbJO5tQ1&t=ffffffffcf4a174e" type="text/javascript"></script> <script src="/ScriptResource.axd?d=uLRCwOuJA-xwtRRow_E7Hq0v5K1DXj8YRZ2chYicyCfUqwvvfXR2C1xI7mel65lGuhK3m71Yx952aE6WQ4vkzg2&t=ffffffffcf4a174e" type="text/javascript"></script> <div class="aspNetHidden"> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBgL/046PAQLBv5udDwLBv5udDwLO0LHzAwLP0LHzAwL9nO2QARGzTJ5Kcho1tzVM3gIXWgrV275r13MCRT/Kb4EgrVKR"> </div> <div id="pnlMain"> <div id="UpdateProgress1" style="display:none;" role="status" aria-hidden="true"> <div id="overlay"> <div id="modalprogress"> <div id="theprogress"> <i style="background: #ffffff;" class="fa fa-spinner fa-spin fa-3x stat-elem"></i> </div> </div> </div> </div> <script type="text/javascript"> //<![CDATA[ Sys.WebForms.PageRequestManager._initialize('scrpt1', 'form1', ['tpnlMain','pnlMain'], [], [], 1000, ''); //]]> </script> <div> <div> <table> <tbody><tr> <td> <div id="report_Entity" class="RadComboBox RadComboBox_Silk" style="width:160px;white-space:normal;"> <!-- 2013.1.220.40 --><table summary="combobox" style="border-width:0;border-collapse:collapse;width:100%" class=""> <tbody><tr> <td class="rcbInputCell rcbInputCellLeft" style="width:100%;"><input name="report_Entity" type="text" class="rcbInput radPreventDecorate rcbEmptyMessage" id="report_Entity_Input" value="Select Entity" autocomplete="off"></td><td class="rcbArrowCell rcbArrowCellRight"><a id="report_Entity_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a></td> </tr> </tbody></table><div class="rcbSlide" style="z-index:6000;"><div id="report_Entity_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Silk " style="display:none;"><div class="rcbScroll rcbWidth" style="height:200px;width:100%;"><ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;"><li class="rcbItem ">ALL</li><li class="rcbItem ">SPCG0033</li></ul></div></div></div><input id="report_Entity_ClientState" name="report_Entity_ClientState" type="hidden" autocomplete="off"> </div> </td> <td> <select name="report_Type" onchange="javascript:setTimeout('__doPostBack(\'report_Type\',\'\')', 0)" id="report_Type" class="selectbox"> <option selected="selected" value="">Report Type</option> <option value="1">Total Subscriber List</option> <option value="2">Subscriber List with Active Package</option> </select> </td> <td> </td> <td> <input type="submit" name="btn_new" value="Show Data" id="btn_new" class="button"> </td> <td> </td> <td> </td> </tr> </tbody></table> </div> <span id="lbl_error" style="color:White;font-weight:bold;"></span> <div> </div> </div> </div> <script type="text/javascript"> //<![CDATA[ Sys.Application.add_init(function() { $create(Sys.UI._UpdateProgress, {"associatedUpdatePanelId":"pnlMain","displayAfter":0,"dynamicLayout":true}, null, null, $get("UpdateProgress1")); }); WebForm_InitCallback();Sys.Application.add_init(function() { $create(Telerik.Web.UI.RadComboBox, {"_dropDownWidth":0,"_height":200,"_postBackReference":"__doPostBack(\u0027report_Entity\u0027,\u0027arguments\u0027)","_skin":"Silk","_uniqueId":"report_Entity","clientStateFieldID":"report_Entity_ClientState","collapseAnimation":"{\"duration\":450}","emptyMessage":"Select Entity","expandAnimation":"{\"duration\":450}","itemData":[{},{"value":"SPCG0033"}],"localization":"{\"AllItemsCheckedString\":\"All items checked\",\"ItemsCheckedString\":\"items checked\",\"CheckAllString\":\"Check All\"}","markFirstMatch":true}, null, null, $get("report_Entity")); }); //]]> </script> </form> </body></html>
If you look at the <input id="report_Entity_ClientState" ... > node the type is hidden. So we have to unhide the WebElement first and send the chars as follows: entityElem = browser.find_element_by_xpath("//input[#id='report_Entity_ClientState']") browser.execute_script("arguments[0].removeAttribute('type')", entityElem); entityElem.send_keys('Entity1')
browser.switch_to.frame("ContentPlaceHolder1_myIframe") I had to add this line just before trying to find an element. Now all the methods mentioned by #DebanjanB and #Ratmir Asanov works perfectly. Thank you for your constant support.