selenium

unknown error: failed to wait for extension background page to load: chrome-extension error loading an extension to Chrome Headless using Selenium

十年热恋 提交于 2021-01-29 10:31:12
问题 I try to run chromedriver via selenium in headless mode. IMPORTANT The code runs perfectly fine if I eliminate the following code lines (but is not headless): chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') This is the error I get when I try to implement the headless argument: Traceback (most recent call last): File "camel_amazon_scraper.py", line 83, in <module> executable_path=executable_path) File

how to select a value from dynamic searchbox in selenium webdriver java?

心已入冬 提交于 2021-01-29 10:18:56
问题 enter image description here I have to select a name from this searchbox based on my input value. How I can achieve this. 回答1: Option 1: If html tag for Account name is <select>...</select> , you can use org.openqa.selenium.support.ui.Select See https://www.guru99.com/select-option-dropdown-selenium-webdriver.html Option 2: Use relationship parrent-child of elements. See Selenium Java : Dropdown items are updated dynamically and https://www.tutorialspoint.com/locating-child-nodes-of

Selenium doesn't quit on KeyboardInterrupt (Python)

陌路散爱 提交于 2021-01-29 10:14:33
问题 I'm trying to close Firefox instance that my app has opened when user interrupts the program. But selenium doesn't close the window. Here is a sample code that shows the problem: import time from selenium import webdriver driver = webdriver.Firefox() try: while True: driver.get("https://google.com") time.sleep(5) except KeyboardInterrupt: print("Quitting") driver.quit() print("Done") When I hit Ctrl+C, I see "Quitting" printed on the console, a few moments later, I see "Done" printed to the

Selenium WebDriver - Unable to drag and drop element in IE11

≡放荡痞女 提交于 2021-01-29 09:55:51
问题 I am trying to drag and drop an element from side panel to form. Drag and drop code what I wrote is like below. Actions builder = new Actions(driver); builder.dragAndDrop(source, target).build().perform(); This works fine in all browser except IE11. I tried other approaches like Approach 1 - builder.clickAndHold(source) .moveToElement(target) .release(target) .build() .perform(); Approach 2 - builder.clickAndHold(source) .pause(Duration.ofSeconds(1)) .moveByOffset(-1, -1) .pause(Duration

How to Mouse Hover over different images with dynamic xpaths through Selenium Java

隐身守侯 提交于 2021-01-29 09:51:07
问题 There are seven images. I want to do mouse hover on every image and and check AddToCart button is displayed or not. I have tried following code and it is not working. Reference: http://automationpractice.com/index.php public boolean checkMouseHoveronAllItems(WebDriver driver) { String xpathOfItems="//[@id='homefeatured']/li['+index+']/div/div[1]/div/a[1]/img"; String xpathOfAddToCartButtons="//div[@class='button-container']/a[@title='Add to cart']"; boolean res=false; for(int index=1;index<

Issues adding WebDriverWait in a for loop - selenium

无人久伴 提交于 2021-01-29 09:45:13
问题 I have the following code, which runs well: titles = results.find_elements_by_class_name("docsum-title") for title in titles: print(title.text) It prints out a list of titles from the find_elements_by_class_name . The title's are also hrefs which I want to click to. However, once I add click functions on title.text hyperlinks that go to a new page, (code below) titles = results.find_elements_by_class_name("docsum-title") for title in titles: print(title.text) title_wait = WebDriverWait(driver

Alert Python Selenium, Chrome WebDriver: switch to alert doesn't work

心已入冬 提交于 2021-01-29 09:39:01
问题 Dismissing the alert doesn't work. I get an error every time, I'm using python and working with chrome webdriver. Passing login and password works fine. I would really appreciate some help:) Thanks:D from selenium import webdriver import time browser = webdriver.Chrome('My chromedriver path') a = 1 while a == 1: try: browser.get('https://www.facebook.com/') time.sleep(2) l = browser.find_element_by_id('email') l.send_keys('myphonenumber') l = browser.find_element_by_id('pass') l.send_keys(

Python selenium enable logging with Firefox webdriver

柔情痞子 提交于 2021-01-29 09:30:22
问题 There seems to be a problem with my implementation but I'm not sure what the problem might be. It would be really helpful if I could check the log files (as mentioned in the exception): WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. but the process doesn't write anything to the file I designate as the log file. from selenium import webdriver from selenium.webdriver

How to launch Chrome Extension using Automation (Robot Framework, etc.)

让人想犯罪 __ 提交于 2021-01-29 09:27:42
问题 I need to launch a particular chrome extension in my automation. I am currently using Selenium with Java. But I am unable to launch my chrome extension. 回答1: Basicaly there are two approaches. 1. install desired extension in runtime - https://dev.to/razgandeanu/testing-chrome-extensions-with-selenium-491b 2. manualy install desired extension do existing browser profile and use the existing profile in selenium . Like this: package packageName; import org.openqa.selenium.WebDriver; import org

Add variable in XPath in Python

泪湿孤枕 提交于 2021-01-29 09:13:10
问题 While doing automation, I have to check that email which I am entering is correct one or not. Unfortunately, while creating XPath, UIAutomator is showing me the text of my email address. I want to make XPath dynamic, so, that every time, I use that XPath, It gets the text. Let us suppose: email = 'testqatp@gmail.com' and XPath is: [@text='email'] How is that gonna work? 回答1: if are talking about an input maybe an xpath like this xpath='//input[text()="'+email'"]' give it a go :) 回答2: The