Aug-22-2018, 08:24 PM
Hello, I am trying to send a simple query to google using selenium, but instead of typing spaces it presses the enter key. I even tried making it type letters one by one and it still does the same.
It works correctly in an Ubuntu VM I have in my laptop but when migrating to an Ubuntu server it sends enter when it should send space.
Below is my code (all the additional imports are for other things the code is going to do).
The code below should type "Hello my friend" into the textbox but instead it is typing "Hello" and pressing enter.
How can I fix this?
Thank you very much for your help
It works correctly in an Ubuntu VM I have in my laptop but when migrating to an Ubuntu server it sends enter when it should send space.
Below is my code (all the additional imports are for other things the code is going to do).
The code below should type "Hello my friend" into the textbox but instead it is typing "Hello" and pressing enter.
How can I fix this?
Thank you very much for your help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# -*- coding: utf-8 -*- import datetime import pandas as pd import errno import glob import json import logging import os import random import re import requests import signal import shlex import subprocess import urllib from selenium.webdriver.common.keys import Keys from bs4 import BeautifulSoup from argparse import ArgumentParser from functools import wraps from subprocess import call from time import sleep from web2screenshot import make_screenshot from DataSource import SearchDB from selenium import webdriver from selenium.webdriver.chrome.options import Options from fake_useragent import UserAgent options = Options() options.add_argument( "--no-sandbox" ) options.add_argument( "--window-size=1920,1080" ) options.add_argument( "--start-maximized" ) browser = webdriver.Chrome(chrome_options = options) browser.implicitly_wait( 99 ) browser.set_page_load_timeout( 99 ) testkey = "Hello My Friend" input_element = browser.find_element_by_name( "q" ) for letter in testkey: input_element.send_keys(letter) browser.quit |