YasserKhalil
YasserKhalil

Reputation: 9548

Element click intercepted: Element is not clickable at point (x, x) selenium python

In the html source, I have an iframe and when using selenium python I have used the following lines to activate the iframe then to click a button on it

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'StudentFrame')))
saveButton = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[@ng-click="SaveForm(false)"]')))
driver.execute_script("arguments[0].scrollIntoView();", saveButton)
saveButton.click()

And here's the html part for the iframe

<iframe id="StudentFrame" style="width:100%;height:100%;border:none;" src="/home/EditStudentData?StudentCode=456405881" cd_frame_id_="5182414dc08070439fe276f97f9c4d21">
                    </iframe>
                    
<html><head><style>@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>
    |
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&amp;display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
    <link href="/wwwroot/css/slick-theme.css" rel="stylesheet">
    <link href="/wwwroot/css/styles.css" rel="stylesheet">
    <link href="/wwwroot/css/popupwindow.min.css" rel="stylesheet">

    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.0/angular.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


    <!--  <script src="~/wwwroot/js/Reg.es5.min.js"></script> -->
    <script src="/wwwroot/js/Reg.js"></script>
    
</head>
<body style="font-size: large;" dir="rtl">
    <div class="container-fluid">
        <div class="p-2 text-center">
            <img src="/wwwroot/css/images/logo.png" width="130" alt="">

        </div>
       
        
<h3 class="form-title">yyy</h3>

<div id="FormContainer" ng-app="RegistrationModule" ng-controller="RegistrationController" class="ng-scope">


    <div style="color: red;text-align: center;color: red;text-align: center;background-color: khaki;border-radius: 20px;">تنبيه هام</div>
    <div style="padding-top:16px;padding-bottom:16px;">
        <div style="margin-left: auto;margin-right: auto;padding-left: 16px;padding-right: 16px;background-color: gainsboro;border-right: 20px solid crimson;">
            <div style="color: green;">
                يمكنك حفظ البيانات فى أى وقت ولكى تتمكن من طباعة الإستمارة ينبغى أن تضغط على مفتاح (اعتماد)
            </div>
            <div style="color: green;">
                بعد الإعتماد لن يمكنك تعديل البيانات مرة أخرى ولكن يمكنك طباعة الإستمارة فى أى وقت
            </div>
            <div style="color: #f00;">
                فى حالة وجود بيانات خاطئة
                يرجى التوجه لمسئول المعلومات بمدرستك لتعديل بياناتك وذلك قبل اعتماد الإستمارة
            </div>
        </div>
    </div>

    
            <div class="card">
                <div class="card-header">
                    <div>بيانات الطالب الأساسية </div>
                    
                </div>
                <div class="card-body">
                    <div class="container-fluid">

                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">اسم الطالب</div>
                            <div class="col-xs-12 col-md-10">
                                <div class="form-control">
                                    ايه عكوش عثمان ناجي
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">كود الطالب</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">
                                    456405881
                                </div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">جنسية الطالب</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">
                                    مصرى
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">الرقم القومي</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">30606043300148</div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">محافظة الميلاد</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">مطروح</div>
                            </div>
                        </div>


                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">صورة الطالب</div>
                            <div class="col-xs-12 col-md-10">
                                <div style="display:inline-block;">
                                    <button ng-click="AddImage()" ng-show="EditImage() == true">تحميل الصورة</button>
                                </div>
                                <div style="display:inline-block;margin-left:12px;">
                                    <img style="width: 70px; height: 80px;margin-bottom:12px;" id="StudentImage">
                                </div>
                                <div style="margin:8px;margin-bottom:4px;color:#f00;">
                                    <div>
                                        صورة شخصية واضحة مقاس 4 * 6 تظهر كامل الوجه ، ويفضل أن تكون بخلفية بيضاء مع العلم بأن الصورة المرفقة ستكون على جميع الشهادت والوثائق الرسمية.
                                    </div>
                                    <div style="margin:8px; margin-top:4px;">
                                        يمكنك التقاط الصورة من خلال الموبايل
                                    </div>

                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">تاريخ الميلاد</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">4/6/2006</div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">النوع</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">انثى</div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">محافظة العنوان</div>
                            <div class="col-xs-12 col-md-4">
                                <select ng-show="ReadOnly != true" ng-model="SaveModel.Address_GOV_Code" class="ng-pristine ng-untouched ng-valid ng-not-empty">
                                    <option value="0" ng-selected="gov.Id == 0"></option>
                                    <!-- ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:1">القاهرة</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:2">الإسكندرية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:3">بورسعيد</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:4">السويس</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:11">دمياط</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:12">الدقهلية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:13">الشرقية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:14">القليوبية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:15">كفر الشيخ</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:16">الغربية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:17">المنوفية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:18">البحيرة</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:19">الاسماعيلية</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:21">الجيزة</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:22">بنى سويف</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:23">الفيوم</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:24">المنيا</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:25">اسيوط</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:26">سوهاج</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:27">قنا</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:28">أسوان</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:31">البحر الاحمر</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:32">الوادي الجديد</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:33" selected="selected">مطروح</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:34">شمال سيناء</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:35">جنوب سيناء</option><!-- end ngRepeat: gov in Govs --><option ng-repeat="gov in Govs" ng-value="gov.Id" ng-selected="gov.Id == SaveModel.Address_GOV_Code" class="ng-binding ng-scope" value="number:36">الاقصر</option><!-- end ngRepeat: gov in Govs -->
                                </select>
                                <div class="form-control ng-hide" ng-show="ReadOnly == true">مطروح</div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">قسم / مركز الشرطة</div>
                            <div class="col-xs-12 col-md-4">
                                <select ng-show="ReadOnly != true" ng-model="SaveModel.Police_Station_Code" class="ng-pristine ng-untouched ng-valid ng-not-empty">
                                    <option value="0" ng-selected="0 == SaveModel.Police_Station_Code"></option>
                                    <!-- ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:352">قسم مرسى مطروح</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:353">قسم الحمام</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:354">قسم السلوم</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:355" selected="selected">قسم الضبعة</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:356">قسم سيدى برانى</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:357">قسم سيوه</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:358">قسم مارينا العلمين السياحية</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:359">الساحل الشمالى-جزء</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:360">قسم النجيلة</option><!-- end ngRepeat: ps in GovPoliceStations() --><option ng-repeat="ps in GovPoliceStations()" ng-value="ps.Id" ng-selected="ps.Id == SaveModel.Police_Station_Code" class="ng-binding ng-scope" value="number:361">قسم العلمين</option><!-- end ngRepeat: ps in GovPoliceStations() -->
                                </select>
                                <div class="form-control ng-hide" ng-show="ReadOnly == true">قسم الضبعة</div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">العنوان بالتفصيل</div>
                            <div class="col-xs-12 col-md-10">
                                <input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-valid-maxlength ng-not-empty" style="width:100%;" ng-model="SaveModel.address" ng-show="ReadOnly != true" maxlength="50">
                                <div class="form-control ng-hide" ng-show="ReadOnly == true">السوينية /جلال /الضبعة</div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label">أقرب رقم تليفون</div>
                            <div class="col-xs-12 col-md-4">
                                <input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty" style="width:100%;" ng-model="SaveModel.telephone" ng-show="ReadOnly != true">
                                <div class="form-control ng-hide" ng-show="ReadOnly == true">0464943579</div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">رقم المحمول</div>
                            <div class="col-xs-12 col-md-4">
                                <input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty" style="width:100%;" ng-model="SaveModel.mobile" ng-show="ReadOnly != true">
                                <div class="form-control ng-hide" ng-show="ReadOnly == true">01009315205</div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2 form-field-label">اسم الوالد</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">عكوش عثمان ناجي</div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">مهنته</div>
                            <div class="col-xs-12 col-md-4">
                                <input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty" style="width:100%;" ng-model="SaveModel.father_job" ng-show="ReadOnly != true">
                                <div class="form-control ng-hide" ng-show="ReadOnly == true">مزارع</div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label">البريد الالكتروني</div>
                            <div class="col-xs-12 col-md-10 col-xs-12 ">
                                <div class="form-control" style="direction:ltr;">[email protected]</div>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
            <div class="card" style="margin-top:16px;">
                <div class="card-header">
                    <div>بيانات القيد الدراسى</div>
                </div>
                <div class="card-body">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label">المديرية التعليمية</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">مطروح</div>
                            </div>
                            <div class="col-xs-12 col-md-2  form-field-label"> الإدارة التعليمية</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">الضبعة</div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label">المدرسة</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">السوينية الاعدادية</div>
                            </div>
                            <div class="col-xs-12 col-md-2  form-field-label">حالة الطالب</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">ناجح ومنقول </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label"> نوعية التعليم</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">طالب نظامى</div>
                            </div>
                            <div class="col-xs-12 col-md-2  form-field-label"> نظام التعليم</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">رسمى</div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label"> المرحلة الدراسية</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">اعدادى</div>
                            </div>
                            <div class="col-xs-12 col-md-2  form-field-label"> الصف</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">الصف الثالث</div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-12 col-md-2  form-field-label">اللغة الأجنبية الأولى</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">لغة انجليزية</div>
                            </div>
                            <div class="col-xs-12 col-md-2 form-field-label">اللغة الأجنبية الثانية</div>
                            <div class="col-xs-12 col-md-4">
                                <div class="form-control">معفي</div>
                            </div>
                        </div>


                    </div>

                </div>
            </div>

            <div style="padding:16px;text-align:center;">
               
                <button ng-click="SaveForm(false)" class="btn btn-danger">حفظ</button>
                <button ng-click="SaveForm(true)" class="btn btn-outline-success">اعتماد</button>
                <button ng-click="PrintForm()" class="btn btn-danger">طباعة الإستمارة</button>

                <a href="/account/signout" class="btn btn-danger">خروج</a>
            </div>
            <div style="padding:16px;text-align:center;">
                احتفظ باستمارة التسجيل دون طباعتها لحين طلبها من المدرسة
            </div>
            <div style="padding:16px;text-align:center;color:red;" class="ng-binding">
                
            </div>


            <div class="popup-overlay ng-hide" ng-show="ReportVisible == true" style="display:none;">
                <div class="popup-vertix">
                    <div class="popup-body">
                        <div class="popup-titlebar">
                            <div style="display:inline-block;">

                                <div style="display:inline-block;line-height:1em;vertical-align:middle;margin-right:8px;">ملف الإستمارة</div>
                            </div>
                            <span class="zs-popup-close-button" ng-click="CloseReport()">
                                <img src="/wwwroot/css/images/CRIT_32.GIF">
                            </span>
                        </div>
                        <div class="popup-content">
                            <div class="entity-content" style="display: flex; flex-grow: 1;flex-direction:column;">
                                <div style="text-align:center">
                                    <button ng-click="BtnPrint()" class="btn btn-danger" style="width:250px;">
                                        اطبع الإستمارة
                                    </button>
                                </div>

                                <iframe id="ViewerObject" name="ViewerObject" style="width:100%;height:100%;">
                                </iframe>

                            </div>

                        </div>
                    </div>
                </div>
            </div>

        </div>
<div style="display: none;">
    <input name="__RequestVerificationToken" type="hidden" value="3ffbG-8BsnZsijPgLHDajDYluPsyiAM1Tcw8UMa_mtHJrrL_1WEVhtVHXo86bBVPBOm9Vc0FGPUZ4OYZPCCLTkAt3Nb26RGPyn4usLSAkT41">
</div>

    });
</script>


        <div class="col-12">
            <hr class="whiteHR">
        </div>
        <div class="col-12 text-center">
            <p>
                
            </p>
            <p>
                للشكاوى والإقتراحات برجاء زيارة الرابط  <a href="https://moe-complains.emis.gov.eg/">الشكاوى والإقتراحات</a>
            </p>
        </div>


    </div>


</body></html>

Here's the full code

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

opt = Options()
opt.headless = True
opt.add_experimental_option ("debuggerAddress", "localhost:9090")
driver = webdriver.Chrome(executable_path="D:/Webdrivers/chromedriver.exe", options=opt)
driver.switch_to.window(driver.window_handles[0])

for element in driver.find_elements_by_xpath("//button[@class='button']"):
    print(element.get_attribute('onclick'))
    driver.execute_script("arguments[0].scrollIntoView();", element)
    driver.execute_script("arguments[0].click();", element)
    WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'StudentFrame')))
    saveButton = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="FormContainer"]/div[5]/button[1]')))
    driver.execute_script('arguments[0].scrollIntoView({block: "center"});', saveButton)
    time.sleep(3)
    driver.execute_script("arguments[0].click();", saveButton)
    time.sleep(3)
    
    if 'من فضلك إختر الصورة' in driver.find_element_by_xpath('//div[@class="ng-binding"]').text:
        print(' '*4 + 'Student With No Photo.')
    else:
        WebDriverWait(driver, 10).until(EC.alert_is_present())
        driver.switch_to.alert.accept()
        time.sleep(2)
    
    driver.switch_to.default_content
    time.sleep(5)

print('Finish')

Upvotes: 0

Views: 421

Answers (2)

Prophet
Prophet

Reputation: 33361

In case of such situations you can click that element with JavaScript.
It will work on elements covered by other elements.
However it is not recommended to use JavaScript clicks until you have no alternatives since with Selenium we are trying to imitate real user actins on UI and in case Selenium click doesn't work obviously the same click by user would not work too.
Anyway, the JavaScript click here will look like this:

driver.execute_script("arguments[0].click();", saveButton)

Upvotes: 1

YasserKhalil
YasserKhalil

Reputation: 9548

I have used this line and the problem is solved

driver.execute_script('arguments[0].scrollIntoView({block: "center"});', saveButton)

Upvotes: 0

Related Questions