selenium-webdriver

How to allow or deny notification of microphone and camera popup in Firefox using Selenium WebDriver with Java

旧城冷巷雨未停 提交于 2020-06-12 06:02:16
问题 I am not able to click on the Allow button of access camera authentication popup in Firefox browser using Selenium WebDriver with Java. Below is the code which is using: Map<String, Object> prefs = new HashMap<String, Object>(); WebDriverManager.firefoxdriver().setup(); prefs.put("profile.default_content_setting_values.media_stream_mic", 1); prefs.put("profile.default_content_setting_values.media_stream_camera", 1); prefs.put("profile.default_content_setting_values.notifications", 1); prefs

Can I use Selenium (webdriver) for Chrome without using chromedriver.exe?

扶醉桌前 提交于 2020-06-12 05:05:26
问题 I've been trying to study Selenium in ways we can incorporate it in our testing. I've read and watched some tutorial and it basically needs to use chromedriver.exe set as webdriver.chrome.driver property. However, our company policies restrict us from using/executing exe files. As a result, when I try my code for Selenium chrome, I get an error that the exe trying to execute is unauthorize. So my question is that, is there any way I can use Selenium for chrome without having to use

Wait for page redirection in Protractor / Webdriver

白昼怎懂夜的黑 提交于 2020-06-10 09:06:22
问题 I have a test that clicks a button and redirects to a user dashboard. When this happens Webdriver returns: javascript error: document unloaded while waiting for result. To fix this I insert browser.sleep(2000) at the point where redirection occurs and assuming my CPU usage is low, this solves the issue. However, 2000 ms is arbitrary and slow. Is there something like browser.waitForAngular() that will wait for the angular to load on the redirected page before the expect(..) ? it('should create

What is the difference between driver.switchTo().parentFrame() and driver.switchTo().defaultContent() method in Selenium WebDriver?

大兔子大兔子 提交于 2020-06-10 05:27:09
问题 What is difference between below two methods : driver.switchTo().parentFrame(); driver.switchTo().defaultContent(); 回答1: driver.switchTo().parentFrame(); As per the specifications, driver.switchTo().parentFrame(); invokes the following: Where, the Switch to Parent Frame command sets the current browsing context for future commands to the parent of the current browsing context . As per the Java Docs parentFrame() method changes the focus to the parent context. If the current context is the top

NotADirectoryError: [WinError 267] The directory name is invalid error while invoking Firefox through Selenium Python

…衆ロ難τιáo~ 提交于 2020-06-10 04:05:07
问题 I'm trying to invoke a firefox browser using Selenium webdriver from below python code.. from selenium import webdriver # Initializing the WebDriver for Firefox browser driver = webdriver.Firefox("C:\\selenium\\mozilla\\geckodriver.exe") driver.set_page_load_timeout(30) driver.maximize_window() driver.get("https://www.google.com/") # Closing the reference driver.quit() but it is always throwing an error like below, however this is working for Chrome browser. Traceback (most recent call last):

NotADirectoryError: [WinError 267] The directory name is invalid error while invoking Firefox through Selenium Python

纵然是瞬间 提交于 2020-06-10 04:05:00
问题 I'm trying to invoke a firefox browser using Selenium webdriver from below python code.. from selenium import webdriver # Initializing the WebDriver for Firefox browser driver = webdriver.Firefox("C:\\selenium\\mozilla\\geckodriver.exe") driver.set_page_load_timeout(30) driver.maximize_window() driver.get("https://www.google.com/") # Closing the reference driver.quit() but it is always throwing an error like below, however this is working for Chrome browser. Traceback (most recent call last):

Selenium can't find element by name or id (python)

柔情痞子 提交于 2020-06-10 03:32:05
问题 from selenium import webdriver import os from selenium.webdriver import chrome driver = webdriver.Chrome() driver.get("http://nmcunited.me.showenter.com/%D7%9C%D7%94-%D7%9C%D7%94-%D7%9C%D7%A0%D7%93.html") driver.implicitly_wait(15) christmasTag = driver.find_element_by_id('f_2561406_1') christsmasTag.click() driver.close() I used the python code above in order to practice on some basic Selenium operations. I couldn't find any element, neither by name nor by id. No matter what I tried I always

Using a variable in xpath in Python Selenium

ぃ、小莉子 提交于 2020-06-10 03:27:48
问题 I've been having trouble figuring out how to get a variable to work Selenium. This post seems to have helped (Variable not working inside parenthesis) but I still can't get it to work. When I used the actual value it works. In this case AL-Alabama. I created a variable called state so that I can just call that in my function. I have 13 states to run through. driver.find_element_by_xpath("//option[@value='AL-Alabama']").click() This one uses the state variable and in looking at error message

scrollIntoView() method implementation

亡梦爱人 提交于 2020-06-09 05:32:06
问题 Using javascript we can bring an element into view using - document.getElementById('pluginsource_wrapper').scrollIntoView(); I can understand the concept of scrollIntoView() method but just wanted to know its code and understand how it is implemented. Could you please point me to the code where I can find implementation of scrollIntoView() ? 回答1: scrollIntoView() The scrollIntoView() method scrolls the element's parent container such that the element on which scrollIntoView() is called is

scrollIntoView() method implementation

感情迁移 提交于 2020-06-09 05:32:04
问题 Using javascript we can bring an element into view using - document.getElementById('pluginsource_wrapper').scrollIntoView(); I can understand the concept of scrollIntoView() method but just wanted to know its code and understand how it is implemented. Could you please point me to the code where I can find implementation of scrollIntoView() ? 回答1: scrollIntoView() The scrollIntoView() method scrolls the element's parent container such that the element on which scrollIntoView() is called is