SELENIUM(PYTHON) ERROR: element not interactable

Does anyone know how to click on this particular web element from this site?(https://www.milanofinanza.it/quotazioni/ricerca/listino-completo-2ae?refresh_cens)
enter image description here

I have tried in many different ways but i still get the same error(element not interactable)
my code looks like this:

wd.find_element(By.XPATH,"//*[@id='mainbox']/div[2]/div[2]/div[4]/div/div[1]/div/button[4]").click()

The element is actually detected but for some reason it isn’t clickable.
Thanks in advance

How to add property to object inside another function?

I’ve been struggling with this exercise.

addCharacter: function (name, lastName, house, dateOfBirth, isMuggle)
{
    let id = 0;
    for (let i = 0; i < houses.length; i++) {
      if (house === houses[i]) {
        id = i + 1;
      }
    }
    if (id === 0) {
      return null;
    }
    const date = dateOfBirth.split("-").reverse().join("-");
    const d = new Date(date);
    const year = d.getFullYear();

    const character = {
      name,
      lastName,
      houseId: id,
      dateOfBirth,
      yearOfBirth: year,
      isMuggle,
      wand: {},
      spells: [],
    };

    characters.push(character);
    return character;
}

I need to add properties to wand object with this format {wood: wood, core: core, length: length}

addWand: function (name, wood, core, length) {
    const character = characters.find((character) => character.name === name);

    if (!character) return [];

    if (character.wand !== undefined) {
      return null
    }
}

Been trying with dot notation, assign method and spread operator but I can’t make it work. Thanks in advance.

Why do my https requests hang for several minutes?

I make https request from a react native app. Sometimes the requests hang for about 2 minutes (no reject, no resolve). Here are some symptoms:

  • It looks like it happens only on some network (4G works, wifi doesn’t)
  • It comes and goes (can work 100 times, then stop working)
  • looks like https fails when http succeeds
  • The same requests work perfectly in Chrome (same device, same network)
  • I use react native with expo
  • tried fetch & axios

What else can I check?

Object to new Object with modified values

I have the following question:

I have a “product” from a large object which I get via an API into the frontend. If I want to update this “product”. But not the complete object should be sent to the backend via the API, only the changed values should be sent – of course in the same structure:

Example:

product: {
  name: "Product Name",
  price: {
    netPrice: 100,
    currency: "$"
  },
  properties: {
    a: "Prop A",
    b: "Prop B",
    c: "Prop C"
  }
}

When I just update one property I want an object like this and not the complete object with the changed data (only one value changed):

product: {
  properties: {
    b: "Prop D"
  }
}

UPDATE:
I’m using vue and want to update the object with an form

Is there any best practice for this?

The bar that contains a low value is almost invisible on the chartjs

enter image description here

grafico() {
const bgColor = {
id: ‘bgColor’,
beforeDraw: (chart, steps, options) => {
const { ctx, width, height } = chart;
ctx.fillStyle = ‘white’;
ctx.fillRect(0, 0, width, height);
ctx.restore();
},
};
const ctx = document.getElementById(‘myChart’);
new Chart(ctx, {
type: ‘bar’,
options: {
responsive: true,
maintainAspectRatio: false,
scales: {

      yAxes: [
        {
          beginAtZero:true,
          ticks: {
            callback(value, index) {
              return 'R$' + value;
            },
          },

        },
      ],
      xAxes: [{}],
    },
    legend: {
      display: false,
    },
  },
  plugins: [bgColor],
  data: {
    labels: this.dateChartFormated,
    datasets: [
      {
        type: 'line',
        label: 'R$',
        data: this.finalBalanceChart,
        backgroundColor: 'rgb(0,53,132)',
        borderColor: 'rgb(0,53,132)',
        lineTension: 0,
        fill: false,
      },
      {
        type: 'bar',
        label: 'R$',
        data: this.receivedAmounts,
        backgroundColor: 'rgb(37,126,37)',
        fill: false,
      },
      {
        type: 'bar',
        label: 'R$',
        backgroundColor: 'rgb(233,64,64)',
        borderColor: 'rgb(233,64,64)',
        borderWidth: 1,
        data: this.paymentAmounts,
        fill: false,
      },
    ],
  },
});

}

Bootstrap modal doesn’t display images that were uploaded in django

hello I have a problem to show several images that are in my database when calling the modal, they just don’t show up. I have found little information about it and what I have found seems very difficult to follow. Can you help me explain how it would be to show the images that are in my database through my modal?

HTML

{% for carro in carros %}
<tr>
   <td>{{carro.fecha_registros}}</td>
       {% if carro.fotosCarro %}
   <td>
   <a data-bs-toggle="modal" data-bs-target="#exampleModal">
      <img src="{{carro.fotosCarro.url}}" height="68">
   </a>
   </td>
      {% endif %}
   <td>{{carro.placas}}</td>
   <td>{{carro.año}}</td>
   <td>{{carro.modelo}}</td>
   <td>{{carro.color}}</td>
   <td>{{carro.cliente.nombre}}</td>
</tr>
{% endfor %}

JS

<script>
    $('#exampleModal').on('shown.bs.modal', function () {
    $('#myInput').trigger('focus')
     })
</script>

views.py

def list_cars(request):

    if request.method == 'POST':
        fromdate=request.POST.get('fromdate')
        todate = request.POST.get('todate')
        searchresult = Carro.objects.filter(fecha_registros__range=(fromdate, todate))
        return render(request,'carros/index.html',{'carros':searchresult})

    else:
        displaydata = Carro.objects.all()
    return render(request, 'carros/index.html', {'carros': displaydata})

Why doesnt this docker command wont work?

I’m trying to dockerize a bare-bones react file. In the terminal I typed
docker build -t sample:react-app
and I get the following error message: docker build" requires exactly 1 argument
so then I tried to put use a dot i.e.) docker build -t sample:react-app . then I get this error: failed to solve with front-end dockerfile.v0: failed to create LLB definition: dockerfile parse error line 1: FROM requires either one or three arguments so then I see this is a common issue with the new Docker Version via https://github.com/docker/buildx/issues/426 . So, does anyone know how to fix this? I tried typing export DOCKER_BUILDKIT=0 export COMPOSE_DOCKER_CLI_BUILD=0 into the cli but it didnt fix it.

Vuex Action committing mutation

I have a vue app where I’m trying to send the updated title and subtitle from an input component to the store to mutate the title and subtitle state when saving from the input component. Currently trying to display custom input values on submit and it’s returning blank each time with this error:

Cannot read properties of undefined (reading 'title')

I can’t seem to find a solution to this problem, all the forums I have been on haven’t helped so I really hope someone on here can help me with my problem; would really appreciate it.

Parent.vue

<template>
  <main class="home-page page">
    <div v-if="!editMode">
      <div>
        <span>Title: </span>{{title}}
      </div>

      <div>
        <span>Subtitle: </span>{{subtitle}}
      </div>

      <div>
        <button @click="randomizeTitleAndSubtitle">
          Randomize
        </button>
        <button @click="onEdit">Edit</button>
      </div>
    </div>

    <div v-else>

      <DoubleInput
        :value="{ title, subtitle }"
      />

      <div>
        <button @click="onCancel">Cancel</button>
        <button @click="onSave">Save</button>
      </div>
    </div>
  </main>
</template>

<script>
// @ is an alias to /src
import DoubleInput from '@/components/DoubleInput.vue';
import { mapState, mapActions } from 'vuex';

export default {
  name: 'Parent',
  components: {
    DoubleInput,
  },
  data() {
    return {
      editMode: false,
    };
  },
  computed: {
    ...mapState(['title', 'subtitle']),
  },
  methods: {
    ...mapActions(['randomizeTitleAndSubtitle', 'updateTitleAndSubtitle']),
    onEdit() {
      this.editMode = true;
    },
    onCancel() {
      this.editMode = false;
    },
    onSave() {
      this.editMode = false;
      this.updateTitleAndSubtitle();
    },
  },
  mounted() {
    this.randomizeTitleAndSubtitle();
  },
};
</script>

Child.vue

<template>
  <div>
    <label>Edit Title: </label>
    <input type="text" ref="title" :value="value.title" @input="updateValue()" />

    <label>Edit Subtitle: </label>
    <input type="text" ref="subtitle" :value="value.subtitle" @input="updateValue()" />

  </div>
</template>

<script>
export default {
  name: 'Child',
  props: ['value'],
  methods: {
    updateValue() {
      this.$emit('input', {
        title: this.$refs.title.value,
        subtitle: this.$refs.subtitle.value,
      });
    },
  },
};
</script>

Store

import Vue from 'vue';
import Vuex from 'vuex';
import randomWords from 'random-words';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    title: '',
    subtitle: '',
  },
  mutations: {
    UPDATE_TITLE(state, value) {
      state.title = value;
    },
    UPDATE_SUBTITLE(state, value) {
      state.subtitle = value;
    },
  },
  actions: {
    randomizeTitle({ commit }) {
      const newTitle = randomWords();
      commit('UPDATE_TITLE', newTitle);
    },
    randomizeSubtitle({ commit }) {
      const newSubtitle = randomWords();
      commit('UPDATE_SUBTITLE', newSubtitle);
    },
    randomizeTitleAndSubtitle({ dispatch }) {
      dispatch('randomizeTitle');
      dispatch('randomizeSubtitle');
    },
    updateTitleAndSubtitle({ commit }, value) {
      const payload = {
        title: value.title || null,
        subtitle: value.subtitle || null,
      };

      commit('UPDATE_TITLE', payload);
      commit('UPDATE_SUBTITLE', payload]);
    },
  },
  modules: {
  },
});

How to manipulate my deep nested json in Javascript?

Here is my nested object and I need to add “name”, “children” for all parent nodes, and “name”, “value” for last nodes:

{
    "myObj": {
        "a": {
            "b": {
                "testB1": "10",
                "testB2": "20",
            },
            "c": {
                "testC1": "43",
                "testC2": "",
                "testC3": [
                    {
                        "aa": "34",
                    },
                    {
                        "bb": "43",
                        "cc": "" 
                    },
                ],
                "testC4": {
                    "ee": {
                        "eee1": "11",
                        "eee2": [
                            {
                                "f": "50",
                            },
                            {
                                "i": "70",
                            }
                        ],
                        "eee3": "1"
                    },
                    "ee": "1"
                }
            }
        }
    }
}

Here is what I need (all names and the depth are random):

{
    "name": "myObj", children: [{
        "name": "a", children: [{
            "name": "b", children:[{
                "name": "testB1", value: "10",
                "name": "testB2": value: "20",
            }],
            "name": "c", children: [{
                "name": "testC1": value: "43",
                "name": "testC2": value: "",
                "name": "testC3", children: [
                    {
                        "name": "aa", value: "34",
                    },
                    {
                        "name": "bb", value: "43",
                        "name": "cc", value: ""
                    },
                ],
                "name": "testC4", children: [{
                    "name": "ee", children: [{
                        "name": "eee1", value: "11",
                        "name": "eee2", children: [
                            {
                                "name": "f", value: "50",
                            },
                            {
                                "name": "i", value: "70",
                            }
                        ],
                        "name": "eee3", value: "1"
                    }],
                    "name": "ee", value: "1" 
                }]
            }]
        }]
    }]
}   

Here is my recursive function:

    function visitDescendants(obj, callback) {
        for (const [key, value] of Object.entries(obj)) {
            if (value && typeof value === "object") {
               let newObj = Object.entries(obj).map( ([key,value]) => ({name: key, children: [value]}) );
                // Recurse
                visitDescendants(value, callback);
            } else {
                let newObj = Object.entries(obj).map( ([key,value]) => ({name: key, value: value}) );
                callback(key, value);
            }
        }    
    }

I can iterate through my object, I can build my desire node, I print out all key values at the last level, but I cannot build the whole object:

visitDescendants(obj, (key, value) => {
    console.log(`${key}: ${value}`);
});

I want to save a two pages forms with multiple checkboxes values in database with Laravel 8

I have two pages for making a survey. The first page have a form with the informations of person (firstname, number, city …) when a user submit this first form i take the information to a session a i redirect to a second page we have 15 question to answers with checkboxes, any question could have many answser.
I’m trying to get the answers from the checkboxes in the same session to store them in databases. Each question can have several choices. I’m not sure how to handle this in my controller.
Someone can help me.
thanks in advance
My views page

@extends('layouts.authenticite')

@section('content')

<div class="div-block-36"><img src="{{ asset('public/authenticite/images/aaa.png') }}" loading="lazy" width="676" alt="" class="image-10"></div>
    <section id="contact-form" class="contact-form-2 wf-section">
      <div class="container-5 w-container">
        <p class="paragraph-9 mobile home">Répondez le plus spontanément possible. Il n’y a pas de bonne ni de mauvaise réponse.<br>‍<br>Remplis le formulaire ci-dessous<span class="text-span-3"><strong class="bold-text"> </strong></span></p>
        <div class="w-form">
          <form method="POST" action = "{{ route('test.store') }}"  id="wf-form-Contact-Form" name="wf-form-Contact-Form" data-name="Wf Form Contact Form"    class="form-3">
              @csrf 
            <div class="contact-form-grid">
              <div id="w-node-_573c6b07-3024-7eba-ed02-c2900c89f863-3fbbfe56">
                  <input type="text" class="text-field-5 w-input" maxlength="256" name="prenom" data-name="First Name" placeholder="Prenom" id="First-Name" required=""></div>
              <div id="w-node-_573c6b07-3024-7eba-ed02-c2900c89f865-3fbbfe56">
                  <input type="text" class="text-field-5 w-input" maxlength="256" name="nom" data-name="Last Name" placeholder="Nom" id="Last-Name" required=""></div>
              <div id="w-node-_573c6b07-3024-7eba-ed02-c2900c89f867-3fbbfe56">
                  <input type="email" class="text-field-5 w-input" maxlength="256" name="email" data-name="Email" placeholder="Email" id="Email" required=""></div>
              <div id="w-node-_573c6b07-3024-7eba-ed02-c2900c89f869-3fbbfe56">
                  <input type="tel" class="text-field-5 w-input" maxlength="256" name="telephone" data-name="Contact Phone Number" placeholder="Numéro de téléphone" id="Contact-Phone-Number"></div>
              <div id="w-node-_573c6b07-3024-7eba-ed02-c2900c89f86b-3fbbfe56">
                  <input type="text" class="text-field-5 w-input" maxlength="256" name="ville" data-name="Ville" placeholder="Ville" id="Ville" required=""></div>
            </div><input type="submit" value="Envoyez"  class="submit-button-3 w-button">
          </form>
          
        </div>
      </div>
    </section>
    
@endsection
@extends('layouts.authenticite')


@section('content')


<div class="div-block-36"><img src="{{ asset('public/authenticite/images/aaa.png') }}" loading="lazy" width="676" alt="" class="image-10"></div>
<div class="w-container">
    
   <div class="form-wrapper w-form">
      <form  method="POST" action = "{{ route('questions.store') }}" id="email-form" name="emailform" data-name="Email Form">
          @csrf
         <div data-delay="4000" data-animation="cross" class="step-paginator w-slider" data-autoplay="false" data-easing="ease" data-hide-arrows="true" data-disable-swipe="true" data-autoplay-limit="0" data-nav-spacing="3" data-duration="200" data-infinite="false">
            <div class="mask w-slider-mask">
            
            
               <div class="step w-slide">
                  <div class="collaborate-form-step">
                     <div class="div-block">
                        <div class="pro-bar">
                           <div class="progress">
                              <div class="text-block-6">8%</div>
                           </div>
                        </div>
                     </div>
                     
                     <div class="form-content">
                        <div data-ix="show-content-onslide" class="form-section-title"><span class="text-span">Question 1</span><br>Lesquelles des activités suivantes serais-tu prêt à pratiquer si tu en avais l’occasion ? <br> <span style = "font-style: italic!important;">(Trois choix possibles)</span></div>
                        <div data-ix="show-content-onslide" class="form-title-line"></div>
                        
                        <div data-ix="show-content-onslide" class="form-row w-row">
                           <div class="col w-col w-col-6 w-col-stack">
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Design-2" name="question1" value = "Le ndochi babouche" data-name="UI Design 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Design-2" class="checkbox-label w-form-label" >Le ndochi babouche</span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Design-2" name="question1" value = "Le tir à la corde" data-name="UI Design 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Design-2" class="checkbox-label w-form-label" value = "Le tir à la corde">Le tir à la corde </span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Development-2" name="question1" value = "Le jambo" data-name="UI Development 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Development-2" class="checkbox-label w-form-label" >Le jambo </span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                           </div>
                           <div class="col w-col w-col-6 w-col-stack">
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Development-2" name="question1" value = "La danse" data-name="UI Development 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Development-2" class="checkbox-label w-form-label" >La danse </span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Development-2" name="question1" value = "Le jeu de la brouette" data-name="UI Development 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Development-2" class="checkbox-label w-form-label" >Le jeu de la brouette </span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Development-2" name="question1" value = "Le jeu de poursuite" data-name="UI Development 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Development-2" class="checkbox-label w-form-label" >Le jeu de poursuite  </span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                           </div>
        
                        </div>
                     </div>
                  </div>
               </div>
               
               <div class="step w-slide">
                  <div class="collaborate-form-step">
                     <div class="div-block">
                        <div class="pro-bar">
                           <div class="progress _2">
                              <div class="text-block-6">16%</div>
                           </div>
                        </div>
                     </div>
                     <div class="form-content2">
                        <div data-ix="show-content-onslide" class="form-section-title"><span class="text-span">Question 2</span><br>Comment tu manges le poisson braisé ? <br> <span style = "font-style: italic!important;">(Choix unique)</span></div>
                        <div data-ix="show-content-onslide" class="form-title-line"></div>
                        <div data-ix="show-content-onslide" class="form-row w-row">
                           <div class="col w-col w-col-6 w-col-stack">
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="UI-Design-2" name="question2" value = "Avec les doigts" data-name="UI Design 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="UI-Design-2" class="checkbox-label w-form-label">Avec les doigts</span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                           </div>
                           <div class="col w-col w-col-6 w-col-stack">
                              <label class="w-checkbox checkbox-wrapper">
                                 <input type="checkbox" id="General-2" name="question2" value = "Avec des couverts" data-name="General 2" data-ix="checkbox-ticker" class="w-checkbox-input checkbox-ticker"><span for="General-2" class="checkbox-label w-form-label">Avec des couverts </span>
                                 <div class="checkbox-active-overlay"></div>
                              </label>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
</form>

My Controller

<?php

namespace AppHttpControllers;


use IlluminateHttpRequest;

use AppModelsAuthenticite;

class AuthenticiteController extends Controller
{
    public function Authenticite(){


        return view('authenticite.index');
            
    }
    
    
    public function Store(Request $request){
    
    
    $validatedData = $request->validate([
            'nom' => 'required',
            'prenom' => 'required',
            'telephone' => 'required',
            'email' => 'required',
    ]);
        
        
    if(empty($request->session()->get('authenticite'))){
        
            $authenticite = new Authenticite();
            $authenticite->fill($validatedData);
            $request->session()->put('authenticite', $authenticite);
            
        }else{
            
            $authenticite = $request->session()->get('authenticite');
            $authenticite->fill($validatedData);
            $request->session()->put('authenticite', $authenticite);
        }
        
        
        return redirect('/questions');
    
    }
        
    public function Questions(){
            
        return view('authenticite.questions');
    }
    
    
    public function QuestionsStore(Request $request){
        
        $authenticite = $request->session()->get('authenticite');
        
        $validatedData = $request->validate([
            
            'question1' => 'nullable',
            'question2' => 'nullable',
            'question3' => 'nullable',
            'question4' => 'nullable',
            'question5' => 'nullable',
            'question6' => 'nullable',
            'question7' => 'nullable',
            'question8' => 'nullable',
            'question9' => 'nullable',
            'question10' => 'nullable',
            'question11' => 'nullable',
            'question12' => 'nullable',
            'question13' => 'nullable',
            'question14' => 'nullable',
            'question15' => 'nullable',
    ]);
        
    if(empty($request->session()->get('authenticite'))){
        
            $authenticite = new Authenticite();
            $authenticite->fill($validatedData);
            $request->session()->put('authenticite', $authenticite);
            
        }else{
            
            $authenticite = $request->session()->get('authenticite');
            $authenticite->fill($validatedData);
            $request->session()->put('authenticite', $authenticite);
        }
        
        
        $authenticite = $request->session()->get('authenticite');
        
        $authenticite->save();
        
        return redirect('/success');
        
    }
    
    public function Success(){
        
        return view('authenticite.success');
    }

}

Mes routes

Route::get('/test', [AuthenticiteController::class, 'Authenticite'])->name('test');
Route::post('/test/store', [AuthenticiteController::class, 'Store'])->name('test.store');

Route::get('/questions', [AuthenticiteController::class, 'Questions'])->name('questions');
Route::post('/questions/store', [AuthenticiteController::class, 'QuestionsStore'])->name('questions.store');

Plz i need help

Mongodb- How to $project all items only from an object?

DATA:

[
  {
    "_id": "1",
    "data": {
      "colour": "Blue",
      "size": "12",
    }
  },
  {
    "_id": "2",
    "data": {
      "colour": "Silver",
      "size": "20",
    }
  }
]

I want to remove the data field.

Expected Output:

[
  {
    "_id": "dsfedsfzzdd",
    "colour": "Blue",
    "size": "12",
    
  },
  {
    "_id": "bfffgesdf",
    "colour": "Silver",
    "size": "20",
    
  }
]

Tried it like this:

db.collection.aggregate({
  "$project": { "anyEmptyField?": "$data" }
})

How to do this ?

Are these 2 Regex the same?

Hi I am newbie to coding. Now I am stuck at a place of use of Regex. Can somebody tell me if these 2 regex are the same please? They seem exactly the same to me but only the second will pass the test.

  1. /^(07)d{9}$ | ^(+447)d{9}$ | ^(00447)d{9}$/

  2. /^(07|(+|00)447)d{9}$/