Clicking the button with Selenium Python

I am trying to write python code that clicks the "accept the cookies" button, but it doesn’t work. I could not understand the problem. Can you help me? Here is my code: Note: I am using MS Visual code, and from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time PATH… Read More Clicking the button with Selenium Python

Selenium Python just gives one result

Selenium is only returning me first result. My code: from selenium.webdriver.common.by import By from selenium import webdriver import pandas as pd url = ‘https://www.tajeran-group.de/fahrzeuge/’ PATH = ‘C:\\Users\\czoca\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Python 3.6\\chromedriver.exe’ driver = webdriver.Chrome(PATH) driver.get(url) driver.maximize_window()# For maximizing window driver.implicitly_wait(15)# gives an implicit wait for 20 seconds dealers = driver.find_elements(By.XPATH, ‘/html/body/div[1]/div[4]/div/div[3]/div[1]/div’) for n in dealers: name =… Read More Selenium Python just gives one result

Selenium can't get this class

I’m trying to get the button clicked but Selenium cant reach that class : access-grants__flows-area__create-button container key_cli_btn = self._get_xpath("//div[@class=’/html/body/div/div/div[1]/div/div[3]/div/div[2]/div[2]/div[3]/div[4]/div’") print(key_cli_btn) This xpath is invalid : selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: `Unable to locate an element with the xpath expression //div[@class=’/html/body/div/div/div[1]/div/div[3]/div/div[2]/div[2]/div[3]/div[4]/div’ because of the following error: `SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//div[@class=’/html/body/div/div/div[1]/div/div[3]/div/div[2]/div[2]/div[3]/div[4]/div” is… Read More Selenium can't get this class

Finding elements by class name inside a loop, selenium

I need to scrape in python a page that has some classes that are number like class1, class2, class3, … classN and I would like to locate the text contained in all those classes. I tried using find_element() function: list = [] for i in range(N-1) list.append(driver.find_element(By.CLASS_NAME, "class" + str(i+1) ).text)) but unfortunately I get… Read More Finding elements by class name inside a loop, selenium

XPath – Select Elements at the first level ex: after Html tag all child tags

So say I have a html structure like so <!DOCTYPE HTML> <html> <body><child></child></body> <div></div> <div><child></child></div> <script><child></child></script> <iframe></iframe> <div></div> </html> say I only wanted to get the children of the html tag and not the decendents of these children I would do something like: webDriver.findElements(By.xpath("//html/*[not(*)]")) and perhaps before I run that line I would wait for… Read More XPath – Select Elements at the first level ex: after Html tag all child tags

Cant get logging element

When i was testing my program, it’s end with code 1 here is full error ("Traceback (most recent call last): File "C:\Users\ds072\PycharmProjects\pythonProject\main.py", line 20, in <module> wait.until(EC.element_to_be_clickable((By.XPATH, "/html/body/main/div/div/div/div[1]/div[3]/div[1]/div[1]/input"))).send_keys("my username")") here is my code (https://pastebin.com/RThnY8GY) I have tested alternatives for this value ("/html/body/main/div/div/div/div[1]/div[3]/div[1]/div[1]/input") but with out results :C Please help me >Solution : The following is… Read More Cant get logging element

How to select multiple alternate checkboxes in selenium webdriver

driver.get("183.82.103.245/nareshit/login.php"); driver.findElement(By.name("txtUserName")).sendKeys("nareshit"); driver.findElement(By.name("txtPassword")).sendKeys("nareshit"); driver.findElement(By.name("Submit")).click(); Thread.sleep(3000); driver.switchTo().frame("rightMenu"); List<WebElement> AllCheckboxes = driver.findElements(By.xpath("//input[@type=’checkbox’]"));; int size = AllCheckboxes.size(); System.out.println(size); for(int i=0;i<size;i++) { (AllCheckboxes).get(i).click(); } Thread.sleep(5000); driver.close(); } }How to select multiple alternate checkboxes in selenium webdriver? I have written code for selecting multiple checkboxes at a time. I I wanted to try for clicking on multiple alternate checkboxes. Kindly… Read More How to select multiple alternate checkboxes in selenium webdriver

Where to set the path to webdriver.chrome.driver (Java, Selenium, IntelliJ)?

So I’m working with Selenium IDE and it beautifully generated the code for me. But I have an issue with webdriver. This is the code. package org.example;// Generated by Selenium IDE import org.junit.Test; import org.junit.Before; import org.junit.After; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.JavascriptExecutor; import java.util.*; public class… Read More Where to set the path to webdriver.chrome.driver (Java, Selenium, IntelliJ)?

If else condition else is not working. Java Selenium

I used this condition to get image and image text. But else statement is not working. if(mercuryImage.isDisplayed()); { System.out.println("Imageis displayed"); //Get image text System.out.println("The text of image "+ mercuryImage.getAttribute("alt")); } else { System.out.println("Image is not displayed"); } >Solution : Else statements execute when the condition inside the if statement returns or equals to false. I… Read More If else condition else is not working. Java Selenium