selenium-webdriver

Selenium WebDriver: Open new tab instead of a new window

邮差的信 提交于 2020-01-19 05:11:06
问题 I am using Selenium WebDriver. Every link is opened in a new browser window. It is not convenient for me. How can I change it so that it opens just in new tab? 回答1: Selenium has no ability to switch tabs at the moment. Because of this we force the browser to open links in new windows but since we are able to switch windows we force the browser to take the approach. This may be fixed in a later version 回答2: Selenium has the ability to switch over tabs now-a-days. The below code1: will work for

Unable to locate element of credit card number using selenium python

Deadly 提交于 2020-01-19 01:50:28
问题 I am working to enter info in the input field with using selenium with python. The element I'm trying to access is <input type="tel" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" class="number" data-braintree-name="number" name="credit-card-number" id="credit-card-number" maxlength="22" placeholder="•••• •••• •••• ••••" aria-describedby="field-description-number" style="background-image: url("data:image/png;base64

Tests fail immediately with unknown error: DevToolsActivePort file doesn't exist when running Selenium grid through systemd

佐手、 提交于 2020-01-18 10:58:09
问题 I've been trying to change the way I start the Selenium grid service from a shell script in .rclocal to a systemd service, but it is not working. The script is this: #!/bin/bash java -jar /opt/selenium-server-standalone.jar -role hub -hubConfig hubconfig.json xvfb-run --server-args="-screen 0 2048x1536x24" java -jar /opt/selenium-server-standalone.jar -role node -nodeConfig nodeconfig.json I created two different services as follows: (Stackoverflow won't let me put the contents of the

Tests fail immediately with unknown error: DevToolsActivePort file doesn't exist when running Selenium grid through systemd

萝らか妹 提交于 2020-01-18 10:51:27
问题 I've been trying to change the way I start the Selenium grid service from a shell script in .rclocal to a systemd service, but it is not working. The script is this: #!/bin/bash java -jar /opt/selenium-server-standalone.jar -role hub -hubConfig hubconfig.json xvfb-run --server-args="-screen 0 2048x1536x24" java -jar /opt/selenium-server-standalone.jar -role node -nodeConfig nodeconfig.json I created two different services as follows: (Stackoverflow won't let me put the contents of the

Filling in login forms in Instagram using selenium and webdriver (chrome) python OSX

僤鯓⒐⒋嵵緔 提交于 2020-01-18 04:01:42
问题 I want to log in to instagram using selenium, but I can't seem to enter values into the fields. Here's my script: #go to this address browser.get('https://www.instagram.com') #sleep for 1 seconds sleep(1) #find the 'login' button on homepage login_elem = browser.find_element_by_xpath( '//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a') #navigate to login page login_elem.click() Having trouble from here onwards: #locate the username field within the form unform = browser.find

Filling in login forms in Instagram using selenium and webdriver (chrome) python OSX

不羁的心 提交于 2020-01-18 04:01:27
问题 I want to log in to instagram using selenium, but I can't seem to enter values into the fields. Here's my script: #go to this address browser.get('https://www.instagram.com') #sleep for 1 seconds sleep(1) #find the 'login' button on homepage login_elem = browser.find_element_by_xpath( '//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a') #navigate to login page login_elem.click() Having trouble from here onwards: #locate the username field within the form unform = browser.find

Alert handling in Selenium WebDriver (selenium 2) with Java

一笑奈何 提交于 2020-01-18 03:24:39
问题 I want to detect whether an alert is popped up or not. Currently I am using the following code: try { Alert alert = webDriver.switchTo().alert(); // check if alert exists // TODO find better way alert.getText(); // alert handling log().info("Alert detected: {}" + alert.getText()); alert.accept(); } catch (Exception e) { } The problem is that if there is no alert on the current state of the web page, it waits for a specific amount of time until the timeout is reached, then throws an exception

Elements are identifying successfully but while sending keys getting no such element error

人盡茶涼 提交于 2020-01-17 18:08:24
问题 Elements are identifying successfully but while sending keys getting no such element error. Assert.assertTrue() used for element presence. 回答1: Example of using pageObjects to grab elements: public class Grabber { /* * There exists a plugin in firefox to right click an element, inspect it, then right clicking the element * and copying the xpath and pasting it here. */ private static WebElement element = null; public static WebElement input_box(WebDriver driver, WebDriverWait wait) { wait

Click link under navigation bar in Selenium Webdriver

限于喜欢 提交于 2020-01-17 13:05:37
问题 I am trying to click the link under the navigation bar. I tried driver.findelement in this code snippet. It selects the link but the click event is not taking place. WebElement menu=driver.findElement(By.xpath(".//*[@id='bs-example-navbar-collapse-1']")); //WebElement menu = driver.findElement(By.XPATH("Coplete_navigationbar_xpath")); List<WebElement> List<WebElement> allLinks = menu.findElements(By.tagName("a")); String MenuOptn=""; for (WebElement w : allLinks) { MenuOptn=w.getText(); if

Unable to fit the two expressions into my script

爱⌒轻易说出口 提交于 2020-01-17 08:04:33
问题 I've written a script to scrape documents from a web page using python in combination with selenium. However, the only thing I got stuck is print the value. As selenium doesn't support indexing in text, I can't think further to accomplish this. Taking a look into my code You will get to know what I meant. I've commented out the two lines to be rectified. Thanks in advance. Here is what I've written so far: from selenium import webdriver import time driver = webdriver.Chrome() driver.get(