Chrome Extension : chrome.tabs.executeScript doesn’t work

I am building a chrome extension that opens a search bar upon pressing a hotkey and when enter is pressed it shows dummy results.

I have defined the following files

background.js

chrome.commands.onCommand.addListener((command) => {
    if(command === "launch") {
        chrome.tabs.executeScript({
            file: "insertSearchBar.js"
        });
    }
});

This file launches insertSearchBar.js correctly.

insertSearchBar.js

var div=document.createElement("div");
var innerDiv=document.createElement("input");
...
div.addEventListener('keypress', function(e) {
    if(e.key == "Enter") {
        chrome.tabs.executeScript({
            file: "insertSearchResultView.js"
        });
    }
})

This file doesn’t execute chrome.tabs.executeScript correctly and doesn’t launch a new view on the current tab.

insertSearchResultView.js

var div=document.createElement("div");
document.body.appendChild(div);
var innerDiv=document.createElement("input");
div.appendChild(innerDiv);