webdriverwait

How to extract the dynamic values of the id attributes of the table elements using Selenium and Java

泄露秘密 提交于 2019-12-09 03:37:42
问题 I have a table where each row will have a download link with a (partly) auto-generated id element. The reason for this is that the actual href-element will allways be "#", so the id's separate the downloads. I need to find the name of that id element in the td. That is: I know the table row has an id element, and I know part of the name, and I need to get the exact name. I'm accessing each row one at a time, so I only need to look within ONE td at a time. No need to look through the whole

find and click element which has a changing CSS selector (python)

佐手、 提交于 2019-12-09 03:23:32
问题 I am writing a script which needs to click on an element of a page, however, the CSS selector changes everyday as the element changes it's location. Today it's called: PPTAmFCTable > tbody:nth-child(1) > tr:nth-child(11) > td:nth-child(3) > a:nth-child(1) Yesterday it was: PPTAmFCTable > tbody:nth-child(1) > tr:nth-child(10) > td:nth-child(3) > a:nth-child(1) And tomorrow it might be tr:nth-child(13) or so. I use the following code: def click_element_bycss(browser,css,timeout): element

How to click a hyperlink without any link text

余生长醉 提交于 2019-12-08 11:33:40
问题 I am trying to click on a hyperlink without a link text. I have: <a id="fontColor" href="f?p=420181023:1:12264109389989:1416222:NO::P1_SEMCODE:20190"> <strong>Check</strong> </a> I've tried: driver.findElement(By.xpath("//a[@href='f?p=420181023:1:12264109389989:1416222:NO::P1_SEMCODE:20190']")).click(); Causes No.SuchElementException driver.findElement(By.id("fontColor")).click(); Does nothing I have read different materials from different websites but it seems none mention hyperlinks without

How to open a link embeded in a webelement with in the main tab, in a new tab of the same window using Control + Click of Selenium Webdriver

我的未来我决定 提交于 2019-12-08 04:41:17
问题 There is a link embedded in a web element in the Main Tab, I want to open that link in a new tab in the same window using Selenium Webdriver and python. Perform some tasks in the new tab and then close that tab and return back to the main tab. Manually we will do this by right-clicking on the link and then select "open in new tab" to open that link in new tab. I am new to Selenium. I am using Selenium and BeautifulSoup to web scrape. I only know how to click on a link. I have read through

Difference between driver.manage.wait(long timeout) and Explicit wait

两盒软妹~` 提交于 2019-12-08 00:00:00
问题 Could anyone say the difference use of the : driver.manage().wait(long timeout) and WebDriverWait wait = new WebDriverWait(driver, WAIT_IN_SECONDS) (EXPLICIT WAIT) to understand my future reference. Please pardon me the questions is silly for new bee of my self in automation. Is it the simple form of the explicit wait? 回答1: driver.manage.wait(long timeout) driver.manage.wait(long timeout) is actually the java.lang.Object.wait() method is from the java.lang.Object Class which causes the

Selenium Python does not close the child window

◇◆丶佛笑我妖孽 提交于 2019-12-06 14:10:50
I have webpage which open new browser window on click. I am able to get 2 handles however driver.close() always closes the first/main window. from selenium import webdriver import time driver = webdriver.Chrome() driver.get("file:///D:/blackhole/print.html") han = driver.window_handles print("handles:", han) # gets 1 handle time.sleep(2) click_btn = driver.find_element_by_link_text('Print') click_btn.click() han = driver.window_handles print("handles:", han) # gets 2 handles driver.switch_to_window = han[1] # first element is always first window handle driver.close() # main window close Below

Difference between driver.manage.wait(long timeout) and Explicit wait

醉酒当歌 提交于 2019-12-06 10:29:30
Could anyone say the difference use of the : driver.manage().wait(long timeout) and WebDriverWait wait = new WebDriverWait(driver, WAIT_IN_SECONDS) (EXPLICIT WAIT) to understand my future reference. Please pardon me the questions is silly for new bee of my self in automation. Is it the simple form of the explicit wait? driver.manage.wait(long timeout) driver.manage.wait(long timeout) is actually the java.lang.Object.wait() method is from the java.lang.Object Class which causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this

Selenium action 'move_to_element' doesn't work in Safari because of usupported 'pause' command

三世轮回 提交于 2019-12-06 06:31:34
问题 The next command is failed on Safari browser during automation testing: ActionChains(driver).move_to_element(searchInput).perform() Exception: InvalidArgumentException: Message: Encountered key input source with invalid 'value' in payload: {actions = ({duration = 0;type = pause;}); id = key; type = key;} The whole refined test example: def test_safari2(self): driver = webdriver.Safari() driver.get('https://www.wikipedia.org') locator = (By.ID, 'searchInput') # 1. the line below is passed

Error “Other element would receive the click” in Python

孤者浪人 提交于 2019-12-06 05:00:47
问题 I tried to click a link like this: <div class="loading" style="display:none;"> <p class="btn blue"><span>さらに表示</span></p> <a href="javascript:void(0);" onclick="get_more();"></a> </div> and I used this code: element = WebDriverWait(driver, 30).until(lambda x: x.find_element_by_css_selector(".btn.blue")) # @UnusedVariable element.click() I got an error like this, what can I do to solve it? selenium.common.exceptions.WebDriverException: Message: unknown error: Element <p class="btn blue">...</p

Selenium Web driver wait for long time

这一生的挚爱 提交于 2019-12-05 01:24:59
问题 Can I wait with Selenium Web Driver for a long time period? Even though I can set implicitlywait command like below, it doesn't wait the time that I've given. driver.manage().timeouts().implicitlyWait(5, TimeUnit.MINUTES); Is there anything wrong here? In my case, I need to execute one test case and wait for 4 minutes and then execute the next test case. I use Java here. 回答1: Considering you need to wait for a particular element i'd do something in the lines of a ExplicitWait like below.