Война со строкой поиска Google! id/class элемента
Всем привет!
пожалуй сразу покажу вам кусок кода, а после расскажу в чем проблема!
@org.junit.jupiter.api.Test
public void findNews() {
webDriver.get("https://www.google.ru/");
WebElement inputField = webDriver.findElement(By.className("gLFyf gsfi"));
WebElement findButton = webDriver.findElement(By.className("gNO89b"));
inputField.click();
inputField.sendKeys("программирование");
findButton.click();
}
Пытаюсь сделать запрос в поисковой строке с последующим нажатием для перехода на другую страницу ! По итогу тест рушится, потому что ему не нравится название класса для привязки к элементам (id не имеют, по крайней мере у меня не получилось найти). Ниже ошибка, которую дает терминал
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".gLFyf\ gsfi"} (Session info: chrome=85.0.4183.102) For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'LAPTOP-7UTLMAI1', ip: '192.168.54.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_252' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.102, chrome: {chromedriverVersion: 85.0.4183.87 (cd6713ebf92fa..., userDataDir: C:\Users\devs\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:54693}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true} Session ID: 3304323dcdfed0545d4f6f80f2d56308 *** Element info: {Using=class name, value=gLFyf gsfi}