disired_capabilities = DesiredCapabilities.CHROME
disired_capabilities['loggingPrefs'] = {
'browser':'ALL'
}
driver = webdriver.Chrome(executable_path = chromedriver_path, desired_capabilities = disired_capabilities)
[
'//a[contains(@href,"{}")]'.format(url_fragment.lower()),
'//a[contains(translate(@href, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), "{}")]'.format(url_fragment.upper())
]
length = len(xpaths)
for cnt in range(length):
xpath = xpaths[cnt]
print('# try {}'.format(cnt))
element = None
try:
element = driver.find_element_by_xpath(xpath)
except InvalidSelectorException, e:
print('Exception (ignored): {}'.format(e))
pass
except NoSuchElementException, e:
print('Exception (ignored): {0}'.format(e))
pass
if element != None:
print('Found via {}'.format(xpath))
print(element.get_attribute('outerHTML'))
else:
print('Failed via {}'.format(xpath))
POST
tohttp://127.0.0.1:55105/session/4efe9b351b24b0869d34bf24ca45af0e/chromium/send_command_and_get_result
params: {"cmd": "Page.captureScreenshot", "params": {"clip": {"x": 32, "y": 469, "width": 235, "height": 76, "scale": 1}}}
...
return base64.b64decode(response['value']['data'])
viewport
будет свой) script = "return window.getComputedStyle(arguments[0],':after')";
display.stop()
browser.close()
browser.quit()
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js');
});
Video link selected: https://www.tiktok.com/@egorkreed/video/678***************5
Video link selected: https://www.tiktok.com/@egorkreed/video/678***************7
Video link selected: https://www.tiktok.com/@egorkreed/video/678***************4
...
class waittest:
def __init__(self, locator1, locator2, attr, value):
self._locator1 = locator1
self._locator2 = locator2
self._attribute = attr
self._attribute_value = value
def __call__(self, driver):
element1 = driver.find_element_by_xpath(self._locator1)
# опущена проверка что element1 хороший
element2 = element1.find_element_by_xpath(self._locator2)
if element2.get_attribute(self._attribute) == self._attribute_value:
return element2
else:
return None
driver = webdriver.Firefox()
driver.get('http://www.ubuntu.com/')
try:
element = WebDriverWait(driver, 10).until(
waittest('//*[@id="navigation"]/div/div/div','a[@href="/"]', 'class', 'p-navigation__link')
)
if element != None:
print element.get_attribute('innerHTML')
except TimeoutException:
pass
driver.close()
driver.quit()
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Displaying value of 'something' property</echo>
<echo>[something]: ${something}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Regex.IsMatch(peremennaya.Trim(), "Text")
IWebElement element = Selene.GetWebDriver().FindElement(By.XPath("//*[contains(text(),'Hello World')]"));
StringAssert.Contains("Hello World!" , element.Text);