webdriver

Auto click a button in a web page

我们两清 提交于 2020-06-09 05:22:08
问题 I need to auto click on any of the "Add" buttons in a web page like as the following address: "https://groceries.asda.com/search/yoghurt" But, none of the "Add" buttons in the page has name or id. So I can not use driver.find_element_by_id() command from Selenium package. Can any one help me? 回答1: To click on any particular Add button for a particular product you can write a method as follows: def click_me(string): driver.find_element_by_xpath("//h3/a[@class='co-product__anchor' and contains(

Chromeoptions and setExperimentalOption code

爱⌒轻易说出口 提交于 2020-06-01 01:00:22
问题 I am unable to understand the meaning of following lines of code for setting up Chromeoptions in selenium code Can someone explain its meaning and als provide some external link for further learning -: ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); prefs.put("profile.default_content_setting_values.notifications", 2); options

Chromeoptions and setExperimentalOption code

余生长醉 提交于 2020-06-01 00:59:22
问题 I am unable to understand the meaning of following lines of code for setting up Chromeoptions in selenium code Can someone explain its meaning and als provide some external link for further learning -: ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); prefs.put("profile.default_content_setting_values.notifications", 2); options

How to bring selenium browser to the front?

风格不统一 提交于 2020-05-25 20:04:08
问题 if the browser window is in bg, then this line doesn't work. from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By # available since 2.4.0 from selenium.webdriver.support.ui import WebDriverWait # available since 2.26.0 from selenium.webdriver.support import expected_conditions as EC browser = webdriver.Firefox() browser.get(someWebPage) element = WebDriverWait(browser, 10).until( EC.element_to_be_clickable((By.XPATH, '/

disable-infobars argument unable to hide the infobar with the message “Chrome is being controlled by automated test software” with ChromeDriver v2.36

自作多情 提交于 2020-05-23 09:50:12
问题 I just updated ChromeDriver to newest version - 2.36. In previous versions I've set: ChromeOptions options = new ChromeOptions(); options.addArguments("disable-infobars"); and the "Chrome is being controlled by automated test software" warning bar wasn't displayed. With the same option set, I'm keep seeing it. Do you know how to disable this from appearing in the newest ChromeDriver? Thanks in advance 回答1: disable-infobars flag has been removed in latest Chrome => https://chromium

InvalidArgumentException: invalid argument: Unsupported locator strategy: -custom error with Appium using Selenium ChromeDriver and Chrome

最后都变了- 提交于 2020-05-15 09:04:07
问题 I'm trying to run the test.ai plugin for appium (https://github.com/testdotai/appium-classifier-plugin). It has a custom locator strategy. I set up appium (version 1.13.0, also tried downgrading to 1.9.2-beta.2) and did: 'npm install -g test-ai-classifier' it was installed, as shown: https://i.stack.imgur.com/fwtkt.png I then wrote a simple test to check if everything is set up correctly: import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; import io

How to configure 'watir' to use an existing chrome user profile (created with chrome.exe --user-data-dir)

醉酒当歌 提交于 2020-05-15 04:24:05
问题 Is it possible to configure watir webdriver use an existing chrome user/profile ( created by chrome.exe --user-data-dir=C:\MyChromeUserProfile ) In Firefox it's possible to do the following: ( created a user profile with firefox -P ) profile = Selenium::WebDriver::Firefox::Profile.new(c://MyFFUserProfile) Watir::Browser.new :ff, :profile => profile For Chrome , I tried the following code to no avail: Watir::Browser.new :chrome, :switches => %w['--user-data-dir=c://MyChromeUserProfile'] While

How to configure 'watir' to use an existing chrome user profile (created with chrome.exe --user-data-dir)

拈花ヽ惹草 提交于 2020-05-15 04:24:03
问题 Is it possible to configure watir webdriver use an existing chrome user/profile ( created by chrome.exe --user-data-dir=C:\MyChromeUserProfile ) In Firefox it's possible to do the following: ( created a user profile with firefox -P ) profile = Selenium::WebDriver::Firefox::Profile.new(c://MyFFUserProfile) Watir::Browser.new :ff, :profile => profile For Chrome , I tried the following code to no avail: Watir::Browser.new :chrome, :switches => %w['--user-data-dir=c://MyChromeUserProfile'] While

Selenium WebDriver C# - get text

倖福魔咒の 提交于 2020-05-13 06:21:27
问题 I have this Html element on the page: <li id="city" class="anketa_list-item"> <div class="anketa_item-city">From</div> London </li> I found this element: driver.FindElement(By.Id("city")) If I try: driver.FindElement(By.Id("city")).Text , => my result: "From\r\nLondon". How can I get only London by WebDriver? 回答1: You could easily get by using class-name : driver.FindElement(By.Class("anketa_item-city")).Text; or using Xpath driver.FindElement(By.Xpath("\li\div")).Text; 回答2: You can try this:

Selenium WebDriver C# - get text

十年热恋 提交于 2020-05-13 06:20:26
问题 I have this Html element on the page: <li id="city" class="anketa_list-item"> <div class="anketa_item-city">From</div> London </li> I found this element: driver.FindElement(By.Id("city")) If I try: driver.FindElement(By.Id("city")).Text , => my result: "From\r\nLondon". How can I get only London by WebDriver? 回答1: You could easily get by using class-name : driver.FindElement(By.Class("anketa_item-city")).Text; or using Xpath driver.FindElement(By.Xpath("\li\div")).Text; 回答2: You can try this: