System.err.println("Locale was: " + jTextField1.getInputContext().getLocale());
Locale locale = new Locale("ru", "RU");
Locale.setDefault(locale);
jTextField1.setLocale(locale);
System.err.println("Locale changed to: " + jTextField1.getLocale());
Locale was: en_US
Locale changed to: ru_RU
By.cssSelector
package example;
public class Controller {
@FXML
private Button buttonSave;
@FXML
private TextField textField;
public void actionButtonPressed(ActionEvent event) {
Object source = event.getSource();
if (!(source instanceof Button)) {
return;
}
Button button = (Button) source;
System.err.println("Data: " + textField.getText() + " clicked:" + button.getId());
}
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="502.0" prefWidth="529.0" style="-fx-background-color: #FAF9F0;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="example.Controller">
...
<TextField layoutX="106.0" layoutY="215.0" opacity="0.8" prefHeight="70.0" prefWidth="300.0" promptText="Срок в месяцах"
fx:id="textField">
<font>
<Font name="VAG World Bold" size="11.0" />
</font>
</TextField>
<Button layoutX="106.0" layoutY="303.0" mnemonicParsing="false" prefHeight="70.0" prefWidth="300.0" style="-fx-background-color: #00B850; -fx-cursor: hand;"
text="Посчитать" textFill="WHITE"
fx:id="buttonSave" onAction="#actionButtonPressed">
<font>
<Font name="VAG World Bold" size="20.0" />
</font>
</Button>
final String script = "return arguments[0].value";
WebElement element = driver.findElement(By.cssSelector("input[name=\"clock\"]"));
String value = (String) executeScript(script, element);
System.err.println("current value: " + value);
WebElement element = driver.findElement(By.cssSelector("input[name=\"clock\"]"));
String value = element.getAttribute("value");
System.err.println("current value: " + value);
driver.getPageSource
никогда не будет содержать ничего что этот JavaSrcipt нагенерил - печально но это так.<html>
<head>
<!-- origin: http://www.java2s.com/Tutorials/Javascript/Javascript_Data_Type_How_to/Date_Clock/Create_auto_refresh_clock.htm -->
<script language="JavaScript">
function gettime() {
var date= new Date();
var hr = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
if(m < 10)
{
m = "0" + m
}
if(s < 10)
{
s = "0" + s
}
document.clockform.clock.value = hr + ":" + m + ":" + s;
setTimeout("gettime()", 2400)
}
</script>
</head>
<body onload="gettime()">
<form name="clockform">
<input type="text" name="clock">
</form>
</body>
</html>
driver.getPageSource
время которое эта страничка показывает никогда не узнаете default_downloads_dir = getenv('USERPROFILE' if getenv('OS') == 'NT' else 'HOME') + '/' + 'Downloads'
chromedriver_path = default_downloads_dir + '/' + ('chromedriver.exe' if getenv('OS') == 'NT' else 'chromedriver')
options = Options()
driver = webdriver.Chrome(chromedriver_path, chrome_options = options)
url = 'https://www.w3schools.com/css/tryit.asp?filename=trycss_before'
driver.get(url)
frame_css = 'div#iframewrapper iframe[name="iframeResult"]'
frame_element = driver.find_element_by_css_selector(frame_css)
print(frame_element.get_attribute('outerHTML'))
driver.switch_to.frame(frame_element)
element_xpath = '//h1'
element = driver.find_element_by_xpath(element_xpath)
print( element.get_attribute('innerHTML'))
driver.implicitly_wait(10)
script = 'return window.getComputedStyle(arguments[0],":before")'
data = driver.execute_script(script, element)
print('Result(raw) : {}'.format(data))
for data_key in data:
print('element: {}'.format(data_key))
script = 'return window.getComputedStyle(arguments[0],":before").getPropertyValue(arguments[1]);'
for property_key in ['top', 'left', 'width', 'height', 'content']:
property_value = driver.execute_script(script, element, property_key)
print('element property {} = {}'.format(property_key, property_value))
driver.switch_to.default_content()
driver.close()
driver.quit()
element property top = auto
element property left = auto
element property width = auto
element property height = auto
element property content = url("https://www.w3schools.com/css/smiley.gif")
networks:
- my-network
networks:
my-network:
external: true
а локаль слелал полем инстанса