This is an automated email from the ASF dual-hosted git repository.
qiuxiafan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git
The following commit(s) were added to refs/heads/main by this push:
new 59dcc29 Interacting with web elements through selenium (#201)
59dcc29 is described below
commit 59dcc298726625bd64680cf1d33da6dc1522da7a
Author: Fine0830 <[email protected]>
AuthorDate: Wed Feb 12 13:24:24 2025 +0800
Interacting with web elements through selenium (#201)
---
services/app/frontend/src/components/Form.jsx | 2 +-
.../src/components/InspirationGenerator.jsx | 2 +-
services/app/frontend/vite.config.js | 21 ++++++++++++++++++++-
services/load-gen/loadgen.py | 18 +++++++++++++++++-
4 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/services/app/frontend/src/components/Form.jsx
b/services/app/frontend/src/components/Form.jsx
index 8858605..1d4376f 100644
--- a/services/app/frontend/src/components/Form.jsx
+++ b/services/app/frontend/src/components/Form.jsx
@@ -37,7 +37,7 @@ export default function Form() {
value={message}
onChange={e => setMessage(e.target.value)}
/>
- <button type="submit">Send</button>
+ <button id="sendButton" type="submit">Send</button>
</form>
);
}
diff --git a/services/app/frontend/src/components/InspirationGenerator.jsx
b/services/app/frontend/src/components/InspirationGenerator.jsx
index 0be2e9e..d998b42 100644
--- a/services/app/frontend/src/components/InspirationGenerator.jsx
+++ b/services/app/frontend/src/components/InspirationGenerator.jsx
@@ -30,7 +30,7 @@ export default function InspirationGenerator({children}) {
<>
<p>Your inspirational quote is:</p>
<FancyText text={quote} />
- <button onClick={next}>Inspire me again</button>
+ <button id='quoteButton' onClick={next}>Inspire me again</button>
{children}
</>
);
diff --git a/services/app/frontend/vite.config.js
b/services/app/frontend/vite.config.js
index 83b9d62..a9c4fc9 100644
--- a/services/app/frontend/vite.config.js
+++ b/services/app/frontend/vite.config.js
@@ -1,4 +1,23 @@
-import { defineConfig, transformWithEsbuild } from 'vite'
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react';
export default defineConfig(() => {
diff --git a/services/load-gen/loadgen.py b/services/load-gen/loadgen.py
index 23bfee8..768338d 100644
--- a/services/load-gen/loadgen.py
+++ b/services/load-gen/loadgen.py
@@ -21,6 +21,7 @@ import traceback
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
+from selenium.common.exceptions import NoSuchElementException,
WebDriverException
url = os.getenv('URL', 'http://frontend/index.html')
@@ -33,7 +34,22 @@ while True:
# noinspection PyBroadException
try:
driver.get(url)
- except Exception:
+ # Click the send button
+ try:
+ send_button = driver.find_element(By.ID, "sendButton")
+ send_button.click()
+ except NoSuchElementException:
+ print("Send button not found")
+ # Click the quote button
+ try:
+ quote_button = driver.find_element(By.ID, "quoteButton")
+ quote_button.click()
+ except NoSuchElementException:
+ print("Quote button not found")
+ except WebDriverException as e:
+ print(f"WebDriver Error: {e}")
traceback.print_exc()
+ break
finally:
time.sleep(10)
+ driver.quit()