I'm using selenium with python and chromedriver and I'm trying to do a script that clicks in a button from multiple taps in the shortest time (<200ms), but until now I was only capable of doing 600ms, I was trying to see if my bottleneck was the way I was switching between tabs so I was trying to use shortcut such as CTRL+TAB and CTRL + T to open them but in my tests, the following lines don't open the tabs. If I try to do it with the keyboard it works.
driver = webdriver.Chrome(executable_path= os.getcwd() + "/Browser-Driver/chromedriver.exe")
driver.get("https://www.google.pt/")
ActionChains(driver).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()
driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
Right now, I'm doing like this where I want a time of +/- 200ms difference. I'm using css_selector because I search and saw that was the fastest. And I'm using the switc_to.window.
aux.driver.switch_to.window(aux.driver.window_handles[1])
first_send = aux.driver.find_element_by_css_selector('#troop_confirm_go')
t = datetime.today()
time_interval_s = (future-t).total_seconds() - duration_s - 0.9
time.sleep(time_interval_s)
first_send.click()
tab_i = 2
for _ in range(len(attacks)-1):
aux.driver.switch_to.window(aux.driver.window_handles[tab_i])
aux.driver.find_element_by_css_selector('#troop_confirm_go').click()
tab_i += 1
The way that I'm opening the tabs is aux.driver.execute_script(f"window.open('{current_url}', 'tab{tab_i}');")
My question is why CTRL+T won't work using actions and send_keys and what is the fastest way to achieve a delay of 200ms where right now I'm having 600ms
Thanks for all the attention! jmmb