selenium-webdriver

Getting text from the last hyperlink tag

我只是一个虾纸丫 提交于 2020-01-30 07:44:25
问题 I'm trying to access hyperlink texts that will always be stored as the last hyperlink tag nested in 100 div tags on a certain website. In the below example, "00A17" would be what I'm trying to extract from a single tag. HTML Code: <div class="headlineText"> <a class="mrnum" title="Full MathSciNet Item" href="/mathscinet/search/publdoc.html?arg3=&co4=AND&co5=AND&co6=AND&co7=AND&dr=all&extend=1&l=100&pg4=AUCN&pg5=TI&pg6=PC&pg7=ALLF&pg8=ET&review_format=html&s4=&s5=&s6=&s7=%22Featured%20Review

PhantomJS with Selenium: Message: 'phantomjs' executable needs to be in PATH

坚强是说给别人听的谎言 提交于 2020-01-30 06:36:13
问题 I having trouble installing PhantomJS to my project Following the suggestions from the similar question from so I defined the $PATH variable with executable path cd Users/zkid18/project/venv/venv_name/lib/python3.6/site-packages/phantomjs-2.1.1/bin export PATH=$PWD Then I try to create a driver with a virtual browser import from selenium import webdriver browser = webdriver.PhantomJS() On this step I got an error No such file or directory: 'phantomjs': 'phantomjs' What I am missing? 回答1: You

How to scroll down on my page through Selenium and Python?

 ̄綄美尐妖づ 提交于 2020-01-29 21:29:33
问题 Trying to scroll down to the bottom of the page https://silpo.ua/offers/?categoryId=13 but there is no result (no movements) My code: import bs4 from selenium import webdriver from selenium.webdriver.common.keys import Keys import time URL = "https://silpo.ua/offers/?categoryId=13" driver = webdriver.Firefox() driver.get(URL) page = driver.find_element_by_tag_name("html") page.send_keys(Keys.PAGE_DOWN) html = driver.page_source 回答1: There are several approaches to scroll down to the bottom of

Python. Selenium. How to wait for new window opens?

允我心安 提交于 2020-01-29 17:48:22
问题 I have a button with twitter, and after click new window opens, but before opening there is a timout in few seconds, so is there a way to wait for it? I mait in a bad way for now... Ui.click_el(link.W9FormNodes.TWITTER_BUTTON) # Wait for new window and switch to it time.sleep(3) aw = driver.window_handles driver.switch_to_window(aw[1]) So I need something better, that will wait only that amount of seconds that needs. I think I solve it in this way. But maybe someone will have comments how to

Disabling JavaScript when using Capybara + Selenium

回眸只為那壹抹淺笑 提交于 2020-01-29 17:45:26
问题 I have an app that's designed to still be functional when JavaScript is disabled, so I wanted to write some specs that covered those cases. I'm using Selenium (Firefox) with Capybara and I'm registering an new driver with JavaScript disabled (via Selenium's javascript.enabled property) # spec/rails_helper.rb Capybara.configure do |config| config.ignore_hidden_elements = true config.default_driver = :selenium end Capybara.register_driver :disable_js do |app| profile = Selenium::WebDriver:

Selenium+firefox: empty execute_script arguments

梦想与她 提交于 2020-01-29 09:04:55
问题 I'm trying to set textarea value using javascript instead send_keys() method. As documentation says, I should be able to pass webelement to execute_script as parameter and refer to this parameter via arguments array. However, I've checked in firefox js console, that arguments is Object and it doesn't matter what i put as execute_script argument - arguments is always an empty object. >>>> web = webdriver.Firefox() >>>> web.get("http://somepage.com") >>>> element = web.find_element_by_tag_name(

Selenium+firefox: empty execute_script arguments

血红的双手。 提交于 2020-01-29 09:04:37
问题 I'm trying to set textarea value using javascript instead send_keys() method. As documentation says, I should be able to pass webelement to execute_script as parameter and refer to this parameter via arguments array. However, I've checked in firefox js console, that arguments is Object and it doesn't matter what i put as execute_script argument - arguments is always an empty object. >>>> web = webdriver.Firefox() >>>> web.get("http://somepage.com") >>>> element = web.find_element_by_tag_name(

How does dot(.) in xpath to take multiple form in identifying an element and matching a text

徘徊边缘 提交于 2020-01-28 12:35:03
问题 I have the below dom structure: <h3 class="popover-title"> <div class="popup-title"> <div class="title-txt">Associated Elements &nbsp(5)</div> </div> </h3> I am trying to write an xpath which will identify the title "Associated Elements" under h3 tag. When my xpath is //div[contains(@class, popover)]//h3[contains(.,'Associated Elements')] the element is identified. However when my xpath is //div[contains(@class, popover)]//h3[contains(text(),'Associated Elements')] the element is not

How does dot(.) in xpath to take multiple form in identifying an element and matching a text

懵懂的女人 提交于 2020-01-28 12:31:51
问题 I have the below dom structure: <h3 class="popover-title"> <div class="popup-title"> <div class="title-txt">Associated Elements &nbsp(5)</div> </div> </h3> I am trying to write an xpath which will identify the title "Associated Elements" under h3 tag. When my xpath is //div[contains(@class, popover)]//h3[contains(.,'Associated Elements')] the element is identified. However when my xpath is //div[contains(@class, popover)]//h3[contains(text(),'Associated Elements')] the element is not

org.openqa.selenium.json.JsonOutput.write(Ljava/lang/Object;Ljava/lang/reflect/Type;) due to JsonException: Attempting to close incomplete json stream

て烟熏妆下的殇ゞ 提交于 2020-01-28 11:22:10
问题 I am getting the above Json exception after I updated my TestNG to 6.14.3 and Selenium to 3.13.0. I am using ChromeDriver() for my automation. Here's a brief idea about my code: @BeforeSuite: System.setProperty("webdriver.chrome.driver", "path to chrome driver"); @BeforeMethod: driver = new ChromeDriver(); @AfterMethod: driver.quit(); My previous Versions were 6.11.0 and 3.7.1 respectively for TestNG and Selenium. The exception is coming when the code tries to start a WebDriver session. The